From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Using WHERE command in property loader SQL query

Solved!
Go to solution

Hello All,

 

Hopefully this will be a fairly straight forward question.

 

I am attempting to use Property Loader to read in test limits from a SQL database. There are many types of models that need to be tested, each having a unique set of limits. I want to be able to retrieve the appropriate limits for the model of product under test.

 

To do this I have the product model number available in a FileGlobal. The database contains a table with the test limit information with an identifying 'ModelNumber_Number' column.

 

I have written the following SQL query achieve this:

 

"SELECT *  FROM TESTLIMITS WHERE ModelNumber_Number=+ FileGlobals.ModelNumber"

 

However, this is where I am confused. I'm not sure on the syntax for accessing a variable in the SQL command. I receive the following error:

 

The multi-part identifier "FileGlobals.ModelNumber" could not be bound.

 

Can someone please provide guidence on how to do this?

 

Many thanks,

 

Cam.

0 Kudos
Message 1 of 4
(3,113 Views)

Add the quotes at proper place:

 

"SELECT *  FROM TESTLIMITS WHERE ModelNumber_Number = " + FileGlobals.ModelNumber

0 Kudos
Message 2 of 4
(3,096 Views)

Thank you very much for your reply.

 

Upon changing the query to as you suggest, I am presented with the following:

 

Error In SQL Statement Expression. "SELECT *  FROM TESTLIMITS WHERE ModelNumber_Number = " + FileGlobals.ModelNumber
Specified value does not have the expected type.

 

The type of FileGlobals.ModelNumber is a numeric represented as a double precision 64 bit signed integer.

 

The database column is also of type int 64.

 

Can you suggest a solution?

 

Many thanks.

0 Kudos
Message 3 of 4
(3,093 Views)
Solution
Accepted by topic author Cam_Roots

Hello, I was able to solve the problem by converting to a string.

 

"SELECT *  FROM TESTLIMITS WHERE ModelNumber_Number = " + str(FileGlobals.ModelNumber)

 

Cheers Cam.

0 Kudos
Message 4 of 4
(3,078 Views)