2

I am doing 1 simple db connection test in Robot framework.I am doing as following-

${queryResults1}  Query  <sql query>

now I want to use the value of ${queryResults1} as input to another query. I am doing

Execute Sql String   select * from customer where customer_id=${queryResults1}

here I am getting error .Execute Sql String doesnot get value of queryresult

how can I do this ?

thanks in Advance!!!

5
  • 1
    please show the actual error. You also need to show what the first query is.Are you fetching a whole row? Multiple rows? A single column from a single row? Commented Oct 27, 2015 at 14:12
  • I am fetching 1 single value/column in first query as below:- Select customer_id from device where macadress='<macaddress>' it returns 1 single value. and the error is - 20151027 21:32:20.153 : FAIL : DatabaseError: ORA-00936: missing expression Commented Oct 27, 2015 at 16:04
  • have you verified that ${queryResults}` is what you expect it to be? Commented Oct 27, 2015 at 16:08
  • log ${QueryResults} is returning me [(629351,)] but when I logged ${queryResults[0][0]} ,I got the correct value 629351. Commented Oct 27, 2015 at 16:31
  • Have you tried using ${queryResults[0][0]} in your second query? Commented Oct 27, 2015 at 16:59

1 Answer 1

1

The problem is that your first query is returning a list of tuples -- a list of rows, each of which is a tuple of columns. Even though you're apparently expecting a single value from a single column in a single row, the data is still in this format. You need to pull the value out of that list of tuples before passing it to your second query.

For example:

Execute Sql String   select * from customer where customer_id=${queryResults1[0][0]}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Bryan.I am new to Robotframework so I am getting stuck almost everytime I use a key :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.