Siebel eFinance Guide > Sample ASPs for Household Financial Accounts Virtual Business Components >

ModelValueBySector.asp


Use the following sample ASP to test retrieving data for the Sector Allocation view.

<%@ EnableSessionState=False Language=VBScript %>

<% option explicit %>

<%

Dim Conn

Dim SQL

Dim R

Dim F

Dim RecsAffected

Dim aConnectionString

aConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _

& "Data Source=C:\Inetpub\ibd\mdb.mdb"

Set Conn = Server.CreateObject("ADODB.Connection")

Conn.Mode = 3

Conn.ConnectionString = aConnectionString

Conn.CursorLocation = 3

Conn.Open

SQL="SELECT * from ModelValueBySector"

Set R=Server.CreateObject("ADODB.Recordset")

dim v

dim fs

dim ts

dim sReq

Dim aPath

Dim aLogFile

dim item

aPath = Request.ServerVariables("PATH_TRANSLATED")

'Response.Write aPath

' strip the file name from the path

aPath = Left(aPath, instrRev(aPath, "\"))

' add the log file name

aLogFile = aPath & "\log\ModelValueBySector.txt"

set fs = Server.CreateObject("Scripting.FileSystemObject")

set ts = fs.OpenTextFile(aLogFile, 8, True, 0)

for each item in Request.ServerVariables

ts.write item

ts.write Request.ServerVariables(item)

next

dim domDoc

dim aFilename

set domDoc = Server.CreateObject("MSXML.DOMDocument")

domDoc.async = false

'domDoc.setProperty("ServerHTTPRequest")=true

domDoc.load(Request)

dim node

dim nodes

dim mainNode

dim mainNodes

dim matchNode

dim matchNodes

dim attribs

dim attrib

dim SQLwhere

Dim root

dim SQLinsert

dim SQLfields

dim SQLvalues

dim sWhere

dim x

dim y

dim sFields

dim sValues

set root = domDoc.documentElement

dim nName

dim inputText

dim data

'inputText = Request.Form("textInput")

nName = root.nodeName

ts.write nName

ts.close

Select Case nName

Case "siebel-xmlext-fields-req"

R.Open SQL, Conn, 3, 1, &H0001

domDoc.save (server.MapPath("init1.xml"))

Response.Write "<?xml version= ""1.0"" encoding=""UTF-8""?>"

Response.Write "<siebel-xmlext-fields-ret>"

For Each F in R.Fields

Response.Write "<support field='"& F.Name &"'/>"

Next

Response.Write "</siebel-xmlext-fields-ret>"

R.Close

Case "siebel-xmlext-query-req"

'This section of SelectCase is for the Query Request

dim attVal1(25)

dim attName1(25)

'set mainNodes = root.childNodes

set matchNodes = domDoc.SelectNodes("siebel-xmlext-query-req/match")

For each matchNode in matchNodes

attVal1(x) = matchNode.text

set attribs = matchNode.attributes

set attrib = attribs(0)

attName1(x) = attrib.nodeValue

x = x +1

next

x = x - 1

for y=0 to x

if not ((x-y)>0) then

sWhere = sWhere & attName1(y) & " = " & """" & attVal1(y) & """"

else

sWhere = sWhere & attName1(y) & " = " & """" & attVal1(y) & """ AND"

end if

next

'setting the WHERE clause in order to query the correct recordset

if sWhere="" then

SQLwhere = SQL

else

SQLwhere = " WHERE " & sWhere

SQLwhere = SQL + SQLwhere

end if

'Response.Write SQLwhere

R.Open SQLwhere, Conn, 3, 1, &H0001

'for debugging

domDoc.save (server.MapPath("init2.xml"))

'build response stream by iterating through the recordset

Response.Write "<?xml version= ""1.0"" encoding=""UTF-8""?>"

Response.Write "<siebel-xmlext-query-ret>"

'ts.write "<?xml version="1.0" encoding="UTF-8"?>"

'ts.write "<siebel-xmlext-query-ret>"

While Not R.EOF

Response.Write "<row>"

'ts.write "<row>"

For Each F in R.Fields

Response.Write "<value field="""& F.Name &""">"& F.Value &"</value>"

'ts.write "<value field="""& F.Name &""">"& F.Value &"</value>"

Next

Response.Write "</row>"

'ts.write "</row>"

R.MoveNext

Wend

Response.Write "</siebel-xmlext-query-ret>"

'ts.write "</siebel-xmlext-query-ret>"

R.Close

Case "siebel-xmlext-preinsert-req"

'Section for PreInsert

Response.Write "<siebel-xmlext-preinsert-ret>"

Response.Write "<row></row>"

Response.Write "</siebel-xmlext-preinsert-ret>"

Case "siebel-xmlext-insert-req"

'Section for Insert

R.Open SQL, Conn, 3, 3, &H0001

dim attVal(25)

dim attName(25)

set mainNodes = root.childNodes

set matchNodes = domDoc.SelectNodes("siebel-xmlext-insert-req/row/value")

For each matchNode in matchNodes

attVal(x) = matchNode.text

set attribs = matchNode.attributes

set attrib = attribs(0)

attName(x) = attrib.nodeValue

x = x +1

next

x = x - 1

for y=0 to x

if not ((x-y)>0) then

sFields = sFields & """" & attName(y) & """"

sValues = sValues & """" & attVal(y) & """"

else

sFields = sFields & """" & attName(y) & """, "

sValues = sValues & """" & attVal(y) & """, "

end if

next

'ts.write sFields

'ts.write sValues

if (R.Supports(&H01000400)) then

R.AddNew Array(sFields), Array(sValues)

end if

R.Update

R.Close

Case "siebel-xmlext-delete-req"

'Section for Delete

End Select

'cleaning up the objects in memory

'ts.close

set root = Nothing

set domDoc = Nothing

set ts = Nothing

set fs = Nothing

Set R = Nothing

Conn.Close

Set Conn = Nothing

%>


 Siebel eFinance Guide 
 Published: 20 October 2003