I'm trying to write to a SQL table using a script. I would like to iterate over data and write many lines to this table. I am currently running my script, getting an error relating to the first entry, and only having the first entry write to the table.
This is the code I'm using:
query = "INSERT INTO NC_Causes (MeltNum, PartNum, StartLot, EndLot, NCCause, Furnace, Date) VALUES (?,?,?,?,?,?,?)"
NCCauses=[melt, PN, SL,EL, NCCause, 'M7', meltTime ]
system.db.runPrepQuery(query, NCCauses)
This is the end of the long error message I get:
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepQuery(INSERT INTO NC_Causes (MeltNum, PartNum, StartLot, EndLot, NCCause, Furnace, Date) VALUES (?,?,?,?,?,?,?), , [6, 0, 0, 0, PD, , M7, Mon Feb 12 23:33:31 PST 2024], )
The entry referenced in the error message is actually getting written to the table, the script just stops after this. Is there any way to skip over the error and just keep the script iterating? This code is currently being run on the script console, but ideally would be run on a timer in the gateway.