Another Newbie question, this on sql in ignition

This statement works in the Script Console but not in a script? Throwing an error on Gateway log.

system.db.runUpdateQuery(“INSERT INTO ProdHist (StationNo, PartCode, PaintColorCode) VALUES (1, 1234, 4321)”)

Gateway log info:

([default]PaintStations/prodsim/Ignition7_9CoreSimulator/Station 1/Spray Status, valueChanged) Error executing tag event script: Traceback (most recent call last): File “”, line 3, in valueChanged at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error( at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runUpdateQuery( at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( java.lang.Exception: java.lang.Exception: Error executing system.db.runUpdateQuery(INSERT INTO ProdHist (StationNo, PartCode, PaintColorCode) VALUES (1, 1234, 4321), , , false)

Thanks in advance…

Also having similar problems with a Select statement that works in Designer Database Query Browser but not in Designer Reporting Module:

select StationNo, PartCode, PaintColorCode from ProdHist

and in Reporting records this error on Gateway log:

com.mysql.jdbc.exceptions.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 ‘OPTION SQL_SELECT_LIMIT=100’ at line 1
at com.mysql.jdbc.SQLError.createSQLException(…

For the reporting problem, I haven’t seen that one before. Can you send that in to support, along with the version of Ignition and the version of the reporting module you’re using, and which database you’re using (MySQL, MsSQL, etc)?

For the first one, gateway scripts are not part of a project, so there is no default database. You’ll need to specify the database as well when doing sql queries in the gateway. Check out the second example here for how to do that.

Just to add to what Kathy said Re: the SQL syntax error: we’ve also seen people have DB issues when the bundled jdbc drivers are incompatible (due to being older versions) with the version of database it’s communicating with. You may want to check the version of the jdbc driver in the gateway config menu, and see if upgrading to a newer one makes sense.