Using Ignition 7.9.10 and SQL Server 2014
I am just trying to run this query
system.db.runUpdateQuery("INSERT INTO acd_history(t_stamp, success) VALUES (%s,1)"%(system.date.format(event.source.parent.startTime, "yyyyMMdd HH:mm:ss")))
where event.source.parent.startTime is just system.date.now(). The error I am getting is
Traceback (most recent call last):
File "<event:actionPerformed>", line 2, in <module>
java.lang.Exception: java.lang.Exception: Error executing system.db.runUpdateQuery(INSERT INTO acd_history(t_stamp, success) VALUES (20190220 10:16:20,1), , , false)
caused by Exception: Error executing system.db.runUpdateQuery(INSERT INTO acd_history(t_stamp, success) VALUES (20190220 10:16:20,1), , , false)
caused by GatewayException: SQL error for "INSERT INTO acd_history(t_stamp, success) VALUES (20190220 10:16:20,1)": Incorrect syntax near '10'.
caused by SQLServerException: Incorrect syntax near '10'.
I’ve tried the date with and without hyphens. I also checked to make sure and t_stamp column is of type datetime. What’s going on?
Edit: So I had to put ’ around the date time. Like this "'"+system.date.format(event.source.parent.startTime, "yyyyMMdd HH:mm:ss")+"'"
. Is this the way I have to do it?