Ask a Question

Unable to store correct value returned from database select query

SOLVED
amritathakur
New Contributor

Unable to store correct value returned from database select query

Hi,

 

I'll try to explain the problem with as much detail as possible. In summary I'm trying to read a value from the db and use it in my scripts. 

 

I created a db table variable using database query, query select is "select FIRST 1 ORDER_ID from ORDERS ORDER by ORDER_TIME desc"

 

When I view the result from the  edit DB table variable value, it returns correct expected number which is a numeric value as per the DB schema. 

Screen Shot 2021-11-26 at 1.24.58 PM.png

 

but when I try to read this value in my code using lastOrderID = Project.Variables.OrderID.Value["ORDER_ID"], I get this value which is alpha numeric with decimals in it. 

 

Screen Shot 2021-11-26 at 1.28.14 PM.png

 

 

This is what I get when I try to add database table checkpoint 

 

Screen Shot 2021-11-26 at 2.14.17 PM.png

Can someone help me identify what's wrong here? I have tried retrieving this value using direct script, creating a db table variable and using db query and finally using datatable table checkpoint wizard. No success so far.

1 REPLY 1
Marsha_R
Champion Level 3

Since you are not doing calculations on Order ID, I suggest storing it as a string and working with it that way in your test.  That will avoid the conversion error that you are seeing.  

 

You can use aqConvert to accomplish this:

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/methods.html

cancel
Showing results for 
Search instead for 
Did you mean: