cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

Highlighted
Contributor

How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

How can I  pass the value in Project.Variables.lastAfscId to bus_uid = as show below the SQL Query Text in the keyword test.

 

select subscription_uid from bus_subscription where bus_uid = Project.Variables.lastAfscId

 

 

6 REPLIES 6
Community Hero

Re: How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

Does that query work for you if you hard code a value for bus_uid instead?

Contributor

Re: How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

The query works with hard coded bus_uid. I don't know how to pass the variable to the query.

Community Hero

Re: How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

Okay, I just wanted to make sure that we know the query is good.  Something similar to the code in your first post should work.  What happens when you try the variable?

Community Hero

Re: How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

When setting up an SQL query for a data driven loop in Keyword test, you can't use variables within the query currently.  What I usually end up doing is using script code, create the loop there (where I can then define the query with a variable) and then call a keyword test from within that script loop, passing in any parmaetres that may be needed.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

I try different way but does not work. what is  the syntax for the variable in query?

 

Select Subscription_UID from Bus_Subscription where bus_uid = Project.Variables.lastAfscId;

Select Subscription_UID from Bus_Subscription where bus_uid = "Project.Variables.lastAfscId";

Select Subscription_UID from Bus_Subscription where bus_uid = "'Project.Variables.lastAfscId'";

 

 

 

Contributor

Re: How to pass persistent variable to SQL Query in Keyword Test Data-Driven Loop

That is what I end up doing. Thought if there is a way to pass variable to query in keyword will be much simpler. thanks for the response.

New Here?
Join us and watch the welcome video:
SeptemberNews
Join the September Hub-bub to show off, learn and win