cancel
Showing results for 
Search instead for 
Did you mean: 

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

grice
New Contributor

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
Regards, George
5 REPLIES 5
murugans1011
Regular Contributor

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

create a global variable under project variables and use tat....



select member from members where id= '" & member_id & "'
grice
New Contributor

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

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...



Regards, George
TanyaYatskovska
Community Manager

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


Hi George,


 


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


 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
grice
New Contributor

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

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
Regards, George
TanyaYatskovska
Community Manager

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


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.


 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors