i have a button with below script action performed to run query from Demo2 database while the default database is “Demo” . i got error that caused by MySQLSyntaxErrorException: Table ‘demo2.vw_wodetails’ doesn’t exist
table = system.db.runQuery("SELECT DISTINCT wo_id from demo2.vw_WODetails where process_id ='{Root Container.Tab Strip.selectedTab}'")
system.tag.write("Result",table)
runQuery
accepts a database parameter separate from your query parameter: https://docs.inductiveautomation.com/display/DOC79/system.db.runQuery
1 Like
Thanks a lot Kevin , it working .
i got anther error
This script working find without property reference
table1=system.db.runQuery("select * from [IONSTAGING].[mes].[MES_WMS_INBOUND] WHERE ( Charindex('120000637',CAST(INTF_MESSAGE AS VARCHAR(MAX)))>0 ) order by INTF_CREATION_DATE desc","IONDB",)
system.tag.write("result1",table1)
Same script with property reference ,gave me an error
caused by SQLServerException: Incorrect syntax near 'Dropdown'.`
table1=system.db.runQuery("select * from [IONSTAGING].[mes].[MES_WMS_INBOUND] WHERE ( Charindex('event.source.parent.getComponent('Dropdown').selectedStringValue',CAST(INTF_MESSAGE AS VARCHAR(MAX)))>0 ) order by INTF_CREATION_DATE desc","IONDB",)
system.tag.write("result1",table1)
what's my mistake
Your quotes don’t match: you’re using single quotes as SQL argument, and in the argument, you use single quotes again to get the Dropdown
component.
The best way to solve this is to first get the selected value from the dropdown, and later plug it into the query.
Splitting stuff over multiple lines also makes it easier to debug, as you know what line it’s happening on.
1 Like
Thanks Sanderd,
it’s ok now based in your advise and query working , but the result of the table only table header without data on the rows .