06-13-2012 06:16 PM
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.
Solved! Go to Solution.
06-14-2012 12:34 PM
Add the quotes at proper place:
"SELECT * FROM TESTLIMITS WHERE ModelNumber_Number = " + FileGlobals.ModelNumber
06-14-2012 03:26 PM
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.
06-17-2012 03:40 PM
Hello, I was able to solve the problem by converting to a string.
"SELECT * FROM TESTLIMITS WHERE ModelNumber_Number = " + str(FileGlobals.ModelNumber)
Cheers Cam.