Must Declare Scalar variables error

  • I need help in understanding why I am getting the error "Must Declare Scalar variables"

    In the following script written using QTP

    ' 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)

    MSGBOX "TEST"

    Please can anyone suggest me a solution.

    Thanks

    Archana

  • if you look at your code, you have two other variables that have not been declared as parameters:

    @NEW_ACCOUNT_ID

    @NEW_MSISDN

    you did declare @Val1 and @Val2 already;

    to me it looks like you did a copy/paste to add an UPDATE statement, but left old variable values instead of usin your new ones, maybe?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply