Micro Focus QTP (UFT) Forums
Must declare scalar variables error - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Must declare scalar variables error (/Thread-Must-declare-scalar-variables-error)



Must declare scalar variables error - codegizmo - 10-18-2012

Hi,

I need to execute an SQL statement in which I need to declare and intialize variables and inster and update the table accordingly. I am trying the following statement but in vain. I am getting "Must Declare Static variables" Can someone help me in correcting the query


Code:
' This test was created using HP Quality Center

Dim objDB, objResults, objCon
'Create an object for the database connection
Set objDB = CreateObject("ADODB.Connection")


'Enter the Connection string, where the Data Source Name (DSN) is pointed. Create if the DSN is not created
objDB.ConnectionString = "DSN=ABC;UID=XYZ;Description=ABC;APP=QuickTest Professional;WSID=WDRFC;"

'Open the DB Connection
objDB.open

'Declare and set values to variables
strDclr ="DECLARE @Val1 AS VARCHAR(10); DECLARE @Val2 AS VARCHAR(10);"_
&"INSERT INTO db.table([Val1],[Val2],[Val3])"_
&"SELECT @Val1 AS MSISDN,@Val2 AS TREATMENT_ID FROM table  WHERE MSISDN = @Val1 AND Campaign_ID = @val2"_
&"UPDATE Subscriber_A SET Account_ID = @NEW_ACCOUNT_ID WHERE MSISDN = @NEW_MSISDN"

Set objResults = objDB.Execute(strDclr)


Thanks