So I started with my SQL Code within the Database Query Browser and I was able to do an update query with no issue This is just a basic edit row SQL script so I could make sure I got the syntax correct:
UPDATE sensor_notes
SET operator = 'admin'
WHERE operator = 'rodney'
Then I took this code, and tried to make it dynamic so that the user would be able to edit data within the database based on text fields within the screen. This is what I got:
[code]name = event.source.parent.getComponent(‘Text Field 4’).text
operator = event.source.parent.getComponent(‘Text Field 5’).text
latitude = event.source.parent.getComponent(‘Text Field 2’).text
longitude = event.source.parent.getComponent(‘Text Field 3’).text
description = event.source.parent.getComponent(‘Text Field 1’).text
db = “DB”
updateQuery = “”“UPDATE sensor_data SET name = ?, operator = ?, latitude = ?, longitude = ?, description = ? WHERE name = ?
VALUES (?,?,?,?,?,?)”""
system.db.runPrepUpdate(updateQuery, [name, operator, latitude, longitude, description, name], db)[/code]
Unfortunately, I keep getting an error code
This is the entirety of the error I keep getting:
Traceback (most recent call last):
File “event:actionPerformed”, line 10, in
VALUES (?,?,?,?,?,?), [Sensor 2, Dave, 12.34, 2.4.68, D2, Sensor 2], DB, , false, false)
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(UPDATE sensor_data SET name = ?, operator = ?, latitude = ?, longitude = ?, description = ? WHERE name = ?
VALUES (?,?,?,?,?,?), [Sensor 2, Dave, 12.34, 2.4.68, D2, Sensor 2], DB, , false, false)
caused by Exception: Error executing system.db.runPrepUpdate(UPDATE sensor_data SET name = ?, operator = ?, latitude = ?, longitude = ?, description = ? WHERE name = ?
VALUES (?,?,?,?,?,?), [Sensor 2, Dave, 12.34, 2.4.68, D2, Sensor 2], DB, , false, false)
caused by GatewayException: SQL error for “UPDATE sensor_data SET name = ?, operator = ?, latitude = ?, longitude = ?, description = ? WHERE name = ?
VALUES (?,?,?,?,?,?)”: No value specified for parameter 7
caused by SQLException: No value specified for parameter 7
Ignition v7.7.5 (b2015071516)
Java: Oracle Corporation 1.8.0_51
Any ideas as to what’s going on? It says no value specified for parameter 7, but I only have 6 parameters there, right? I’m just a tad confused as to what’s going on
I’m currently running Version 7.7.5, so I believe that I am up to date on my software as well.
Thanks in Advance for all the help!