Forum Discussion

grice's avatar
grice
New Contributor
11 years ago

How do you (or can you) use variables inside the Data Driven Loop inside the Query Text Window?

I ad a data driven loop with a query text like



select member from members where id = 3



I would like to substitute the 3 for a variable...



SET VARIABLE IN THE MAIN KEYWORD TEST Panel



member_id = 3 



select member from members where id = (Imported variable from the key word test variable member_id)



Is this possible? If so, please tell me how...



Thanks,

George

5 Replies

  • murugans1011's avatar
    murugans1011
    Regular Contributor
    create a global variable under project variables and use tat....



    select member from members where id= '" & member_id & "'
  • grice's avatar
    grice
    New Contributor
    Thanks for the information however when I enter the value in the SQL Results I get and error stating that the value does not exsists...



  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi George,


     


    Let us know from where exactly you are executing the SQL query.


     

  • grice's avatar
    grice
    New Contributor
    Hi and thank you for helping me out.



    I use the Data Loop and select the option "Use a SQL query", enter my connection credentials, and where the panel that the SQL query is supposed to go (where the user can create a query or execute a Query) this is where I put my query



    Select member_id from members where id = 3



    But I want to use a variable for the number 3 i.e. a global variable MemberID.... in the SQL query if it is posible in the Data Loop wizard...



    Thanks,



    George
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi George,


     


    Try specifying the variable in the following way:


    KeywordTests.Test1.Variables.Var1


     


    However, as far as I remember, TestComplete treats an SQL query as a string, and it may not handle the variable properly.