I am kind of confused about this because this worked yesterday and I have no clue what changed… On SQL Server 2014, Ignition 7.8 on Java 8.65
I cannot retrieve the key from an insert using getKey:
Here is a simplified example that fails
A) SQL
create table temp (id int identity (1,1)not null, name varchar(110) null)
ALTER TABLE [temp] ADD CONSTRAINT [PK_temp] PRIMARY KEY CLUSTERED
(
[id] ASC
)
B) Button on window
qry = “INSERT INTO TEMP (name) Values (?)”
v = “I was here”
ts = system.db.runPrepUpdate(qry, [v], getKey=1)
print ts
C) result
Traceback (most recent call last):
File “event:actionPerformed”, line 3, in
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO TEMP (name) Values (?), [I was here], , true, false)
caused by Exception: Error executing system.db.runPrepUpdate(INSERT INTO TEMP (name) Values (?), [I was here], , true, false)
caused by GatewayException: SQL error for "INSERT INTO TEMP (name) Values (?)": A result set was generated for update.
caused by SQLServerException: [b]A result set was generated for update.
[/b]
The INSERT succeeds but the key is not returned and the code errors out
Ideas welcome
Thanks