Fail to write to database with property included inside the SQL query

Greeting,

I face a problem while I am trying to run a SQl query which included Ignition property inside.
If is not available to included property inside the query? or I didnt set up some setting?

My SQL Query=SELECT Item_Name, Item_Weight, t_stamp FROM container WHERE Storage_Bay = {baypopup.bayNo}

{baypopup.bayNo}=property of a template
My database connection and satus are both valid.

error message I get is as below:

Message:


Details:
Exception: Error running query:
SQLQuery(query=SELECT Item_Name, Item_Weight, t_stamp FROM container WHERE Storage_Bay = , database=DB)@5000ms
On: baypopup.baypopup.Template Repeater.templateParams
caused by GatewayException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
caused by MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1

Ignition v7.9.8 (b2018060714)
Java: Oracle Corporation 1.8.0_181

I dont think you should have ‘query=’ inside the SQLQuery

This is my query. I think there is no 'query=' inside it

Once I change it to
SELECT Item_Name, Item_Weight, t_stamp FROM container WHERE Storage_Bay = 1

It work perfectly but i need it to be indirect

Been awhile since I’ve done this… but try adding quotes around the {baypopup.bayNo} portion. Single I think, but maybe double.

Hi Stuart,

single quote and double quote cause no error but cant get data from database

From the original error message, it appears that the property reference is being replaced with an empty string. That suggests a typo in the reference name or in the outer assignment from template holder to that property of the template.

2 Likes

Hi pturmel,

Thanks for trying to help.
At the end it was my keyboard input problem. I change it back to default one and retype the quote symbol then everything work perfectly now.

Hi Stuart,

At the end it was my keyboard input problem. I change it back to default and try with quote symbol again. It works. Thanks

1 Like