Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variable after database query

Status
Not open for further replies.

boatguy

Programmer
Oct 22, 2001
153
US
Hi,

I am working with a GUI tool to build a VXML call center strategy. One block queries an Oracle database to match the callers telephone number to a column called phone. If there isn't a match, I pass the call to another strategy to verbally request customer ID number. If there is a match, I want to grab the Customer ID from the table and pass it to strategy number 3 that sends all collected data to a call center agent.

Here is the complete code from the data dip script:
Code:
<%@ LANGUAGE=VBSCRIPT %>
<% Response.ContentType="text/xml" %>
<!--#include file="StudioIncludes/pagesupport.inc"-->
<!--#include file="StudioIncludes/vxmlsupport.inc"-->
<%
If request.ServerVariables("REQUEST_METHOD") = "HEAD" Then
    Response.End
end if 
%>
<%
        DIM szDriverPsuedoName
        DIM szServerType
        DIM szDSProvider
        Dim szDataBase
        Dim szSpecifiedDBName 'used for SQL server
        Dim noRecord
        Dim nextPage
        noRecord=0
        szServerType =""        
        CALL SetPageItem("PAGEID","DB_DATA1")        
        ON ERROR RESUME NEXT
        
        IF Request.Form.Count <> 0 THEN
		FOR i = 1 to Request.Form.Count
			SESSION(Request.Form.Key(i)) = Request.Form.Item(i)
		next
	ELSE
		Call UpdateQueryString(Request.QueryString)
	END IF
        //Call UpdateQueryString(Request.QueryString)
        
        strLabel = LookUp("ROOTDOCUMENT")
        strQuery = Trim(GetQueryString())

        ''''' Header Section '''''
        strPromptHeaderVXML = chr(60) + "?xml version=""1.0"" ?" + chr(62) + chr(10)
        strPromptHeaderVXML = strPromptHeaderVXML + chr(60) + "vxml version=""2.0""  xmlns='[URL unfurl="true"]http://www.w3.org/2001/vxml'[/URL] application=""" + strLabel  + """" + chr(62) + chr(10)
        strPromptHeaderVXML = strPromptHeaderVXML + chr(60) + "form" + chr(62) + chr(10)
        ''''' Header Section End --- Contd... '''''

        ''''' Body Section '''''
        
        Dim MsgArray,MsgTypes
        Dim bBargein, lPauseTime, lListCount

        szQuery = "SELECT [PS_RI_SRCH_PHON_VW].[CUST_ID] FROM [PS_RI_SRCH_PHON_VW] WHERE [PS_RI_SRCH_PHON_VW].[PHONE] = '[{ANI_IVR}]'"
        szQueryType = "SELECT"
        szDSProvider = "Microsoft ODBC for Oracle"
        szDSProviderLocation = "servername"
        szDataBase = ""
        szUserName = "PSIVR"
        szPassword = "password"
	szSpecifiedDBName = ""
	
    
    
    
   	xLinks  = ARRAY("GoToCollectAcctNumber.asp", "GoToCollectAcctNumber.asp")
   	xEvents = ARRAY("DBERROR", "EMPTY_RECORDSET_ERROR")

    
    
    
    
    nextPage = "PROMPT2.asp"
    
    
        
        '***************************************
        ' replace [{ with a lookup and get the
        ' value dynamically.
        '***************************************
        szQuery1= Split(szQuery,"[{")
        IF NOT ISEMPTY(szQuery1) THEN
            szQuery = szQuery1(LBound(szQuery1))            
            FOR i = (LBound(szQuery1)+1) TO UBound(szQuery1)
            
                '******************************
                'now split to setup the lookup.
                '******************************
                szQuery11 = Split(szQuery1(i),"}]")
                szQuery = szQuery + CStr(LookUp(szQuery11(0))) + szQuery11(1)
            NEXT
        END IF

        szQuery = Replace(szQuery,"&","")
        
        szQuery1= Split(szQuery,"gt;")
        if not ISEMPTY(szQuery1) then
        szQuery = ""
            FOR i = LBound(szQuery1) TO (UBound(szQuery1) - 1)
            szQuery = szQuery + szQuery1(i) + Chr(62)
            NEXT
            szQuery = szQuery + szQuery1(UBound(szQuery1))
        END IF

        szQuery1= Split(szQuery,"lt;")
        if not ISEMPTY(szQuery1) then
            szQuery = ""
            FOR i = LBound(szQuery1) TO (UBound(szQuery1) - 1)
            szQuery = szQuery + szQuery1(i) + Chr(60)
            NEXT
            szQuery = szQuery + szQuery1(UBound(szQuery1))
        END IF
        ''''' Header Section Contd 1 End '''''

        set Db_Conn=server.createobject("adodb.connection")
        if instr("prefix:" + szDSProviderLocation,"[{") > 7 then
            szDSProviderLocation = REPLACE(szDSProviderLocation,"[{","")
            szDSProviderLocation = REPLACE(szDSProviderLocation,"}]","")
            szDSProviderLocation = trim(szDSProviderLocation)
            szDSProviderLocation = LookUpConvert(szDSProviderLocation)
        end if
        DSNtemp = ""
        IF szDSProvider = "Microsoft ODBC for Oracle" THEN
            DSNtemp = DSNtemp & "Provider=MSDASQL;"
            szQuery = REPLACE(szQuery,"[","")
            szQuery = REPLACE(szQuery,"]","")
        END IF

        
        
        IF szDSProvider = "Microsoft ODBC for Oracle" THEN
            DSNtemp=DSNtemp & "DRIVER={" & szDSProvider &"};"
            DSNtemp = DSNtemp & "SERVER=" & szDSProviderLocation &";"
        ELSEIF szDSProvider = "Microsoft Access Driver (*.mdb)" THEN
            DSNtemp=DSNtemp & "DRIVER={" & szDSProvider &"};"
            DSNtemp = DSNtemp & "DBQ=" & szDSProviderLocation &";"         
        ELSEIF szDSProvider = "SQL Server" THEN
            DSNtemp=DSNtemp & "DRIVER={" & szDSProvider &"};"
            DSNtemp = DSNtemp & "SERVER=" & szDSProviderLocation &";"
            DSNtemp = DSNtemp & "Initial Catalog= " & szSpecifiedDBName & ";"
        ELSE
            szQuery = REPLACE(szQuery,"[","")
            szQuery = REPLACE(szQuery,"]","")
            DSNtemp=DSNtemp&"provider=MSDASQL;DRIVER="&szDSProvider&";SERVER="&szDSProviderLocation &";DATABASE="&szDataBase&";"
        END IF
        
        
        DSNtemp = DSNtemp & "Uid=" & szUserName &";"
        DSNtemp = DSNtemp & "Pwd=" & szPassword &";"
        '******************************
        ' Before we open anything
        ' let us give a chance to the
        ' user to change the Query dynamically.
        '******************************
        Process_Begin()

        Db_Conn.Open DSNtemp
	DIM myErrNumber
	myErrNumber = 0
	noRecord=0
	myErrNumber = Err.Number
	IF myErrNumber <> 0 THEN	    
	    errOccured=1
	    Response.AppendToLog Err.Description
        END IF
        '**********************
        'CREATING RECORD SET
        Set RSDB_DATA1= server.createobject("adodb.Recordset") 
        RSDB_DATA1.Open szQuery,DB_Conn        
        myErrNumber = 0
        noRecord=0
        myErrNumber = Err.Number
        IF myErrNumber = 0 THEN
            IF RSDB_DATA1.EOF THEN
                noRecord=1
            else
                noRecord=2
            END IF
        else
            errOccured=1
            Response.AppendToLog Err.Description
        END IF

        '*****************************
        'check if rs is not empty/null
        '*****************************
        IF szQueryType = "SELECT" THEN
            szData = GetXMLFromADORS(RSDB_DATA1,"J")
            Session("RS_DB_DATA1") = szData
        ELSE
            Session("RS_DB_DATA1") = ""
            if myErrNumber =0 then
                noRecord=2
            end if
        END IF
        Process_Anywhere()
        
        SET RSDB_DATA1= nothing
        
        ''''' Body Section - End '''''
        strPromptFooterVXML  = strPromptFooterVXML  +chr(60) + "block" + chr(62) + chr(10)
   
        bSetError = False
        exp_norecord=0
        if not ISEMPTY(xEvents) or errOccured=1  then
            strRecord=0
            for i=lbound(xLinks) to Ubound(xLinks)
            	if noRecord=0 or noRecord=1 then
            		if xEvents(i) = "DBERROR" THEN
            			nextPage = xLinks(i)
            		elseif xEvents(i) = "EMPTY_RECORDSET_ERROR" and noRecord=1  then
            			nextPage = xLinks(i)
            		end if
            	else
            		bSetError=True
            	end if
            next
        END IF
		strPromptFooterVXML  = strPromptFooterVXML  + chr(60) + "goto next='" + Server.URLEncode(nextPage)

        strPromptFooterVXML  = strPromptFooterVXML  + "'"
        strPromptFooterVXML  = strPromptFooterVXML  + " /" + chr(62) + chr(10)
    
    
        strPromptFooterVXML  = strPromptFooterVXML  +chr(60) + "/block" + chr(62) + chr(10)

        ' end of submit in nomatch...

        strPromptFooterVXML  = strPromptFooterVXML  + chr(60) + "/form" + chr(62) + chr(10)
        strPromptFooterVXML  = strPromptFooterVXML  + chr(60) + "/vxml" + chr(62) + chr(10)
        ''''' Footer Section - End '''''

        response.write(strPromptHeaderVXML + strPromptVXML + strPromptFooterVXML )
        Process_End()

        Db_Conn.Close
        if not ISEMPTY(xEvents) then
            ERASE xEvents
            ERASE xLinks
        end if

%>
      <%
		'Can be used for writing the custom code that needs to get 
		'executed before the vxml page starts
		Sub Process_Begin()

		End Sub
		'Can be used for writing the custom code that needs to get 
		'executed before the vxml page ends
		Sub Process_Anywhere()
dim xmlStr

xmlStr = lookup(RS_DB_DATA1)

For example, if the xmlstr is the above shown Recordset, then it can be processed as follows to get the CUST_ID:

SET oXMLDOM = SERVER.CREATEOBJECT("MSXML2.FreeThreadedDOMDocument.4.0")

oXMLDOM.async = False

oXMLDOM.LoadXML(xmlStr)

 If Err then

response.write "Cannot load XML MSXML4 is missing." & Err.Description

RESPONSE.END

 End If

 oXMLDOM.setProperty "NewParser", "true"

 Set Root = oXMLDOM.documentElement

Set NodeList = Root.getElementsByTagName("CUST_ID")

For Each Elem in NodeList

  Cust_Id = Elem.firstChild.nodeValue

Next
		End Sub
		'Can be used for writing the custom code that needs to get 
		'executed after the vxml page ends.can be used for doing cleanup
		Sub Process_End()

		End Sub

Here is the section that I wrote and was hoping would pass the variable CUST_ID:
Code:
dim xmlStr

xmlStr = lookup(RS_DB_DATA1)

For example, if the xmlstr is the above shown Recordset, then it can be processed as follows to get the CUST_ID:

SET oXMLDOM = SERVER.CREATEOBJECT("MSXML2.FreeThreadedDOMDocument.4.0")

oXMLDOM.async = False

oXMLDOM.LoadXML(xmlStr)

 If Err then

response.write "Cannot load XML MSXML4 is missing." & Err.Description

RESPONSE.END

 End If

 oXMLDOM.setProperty "NewParser", "true"

 Set Root = oXMLDOM.documentElement

Set NodeList = Root.getElementsByTagName("CUST_ID")

For Each Elem in NodeList

  Cust_Id = Elem.firstChild.nodeValue

Next

It does not seem to pass the variable CUST_ID to the next page. Any suggestions?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top