question

A Kamphaus avatar image
0 Likes"
A Kamphaus asked Felix Möhlmann answered

What is the correct SQL syntax for this Database Connector Query?

I have successfully connect a model to a SQL database but am having trouble with getting the syntax correct when importing. Ultimately I want to do this with code but have been experimenting using the Import tool while I figure out the syntax. I would like to do a query along the lines of

 SELECT * FROM ItemWorkComplete WHERE Line = "HIGH"

However I get the error: Invalid column name 'HIGH'

capture.pngWhen I try a different statement like the one below it works as expected.

SELECT * FROM ItemWorkComplete ORDER BY Line ASC


I was also able to successfully run the following in the script window. Just can't seem to work out the WHERE clause.

Database.Connection dbConnection = Database.Connection("DBconnector_IIoT_LocalDev");
dbConnection.connect();
string vsQuery = "SELECT * FROM ItemWorkComplete ORDER BY Line ASC ";
Database.ResultSet dbQuery = dbConnection.query(vsQuery);
dbQuery.cloneTo(Table("GlobalTable2"));
dbConnection.disconnect();


Can anyone tell me what I'm missing here? I need to be able to limit what I pull into a table and I was hoping to do it with a query.

sql queriesdatabase connectordatabase import
capture.png (76.8 KiB)
5 |100000 characters needed characters left characters exceeded

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

· Write an Answer
Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered
I haven't worked with database import in FlexSim yet. Possibly the text value "HIGH" might have to enclosed in single quotation marks ( ' ), rather than double ones, in the query.
· 1
5 |100000 characters needed characters left characters exceeded

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Welp that did it :-)

Some times I think I just stare at something too long I forget to try the easy stuff.

Thank you!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.