NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL statement issue

Solved!
Go to solution

I have this PreExpression to an SQL statement step:

 

Locals.SQL_LatestResult = "SELECT UUT_RESULT.ID, UUT_RESULT.UUT_SERIAL_NUMBER, UUT_RESULT.START_DATE_TIME FROM UUT_RESULT WHERE (((UUT_RESULT.UUT_SERIAL_NUMBER) = \"" + Locals.serial + "\") AND ((UUT_RESULT.START_DATE_TIME)=(SELECT MAX(UUT_RESULT2.START_DATE_TIME) FROM UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT.UUT_SERIAL_NUMBER = UUT_RESULT2.UUT_SERIAL_NUMBER)));"

 

Locals.SQL_LatestResult has this value after the PreExpression:

 

SELECT UUT_RESULT.ID, UUT_RESULT.UUT_SERIAL_NUMBER, UUT_RESULT.START_DATE_TIME FROM UUT_RESULT WHERE (((UUT_RESULT.UUT_SERIAL_NUMBER) = "15514011") AND ((UUT_RESULT.START_DATE_TIME)=(SELECT MAX(UUT_RESULT2.START_DATE_TIME) FROM UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT.UUT_SERIAL_NUMBER = UUT_RESULT2.UUT_SERIAL_NUMBER)));

 

 

I get Number of records = 0, if i run the sequence.

If i copy the exact same SQL statement into to Access i get what i want i.e. one record.

 

If i remove this part from the query:

((UUT_RESULT.UUT_SERIAL_NUMBER) = \"" + Locals.serial + "\")

 

I get 388 records which is correct and the same as running it directly in access.

 

What is wrong here ?

 

0 Kudos
Message 1 of 2
(2,110 Views)
Solution
Accepted by topic author NikolajEgeskovOstergaard

I was too quick to post this... it's my own fault, the database link was wrong, so data was to there....

Statements are fine !

0 Kudos
Message 2 of 2
(2,106 Views)