ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

Return values from an insert statement #877

Closed sprinkaan88 closed 1 year ago

sprinkaan88 commented 1 year ago

Is your feature request related to a problem? Please describe. Not related to a problem.

Describe the solution you'd like On inserting into a table that generates a primary key from a sequence, I would like the new primary key from the sequence number returned as an output parameter.

Describe alternatives you've considered Have not come up with an alternative.

Additional context Apologies if this is already a capability, but I have not been able to determine how to do this with this package. It seems possible from Java libraries, assuming the drivers must support it.

bimalkjha commented 1 year ago

@sprinkaan88 You need to use FINAL TABLE to get the primary key as SELECT * FROM FINAL TABLE (INSERT INTO mytab VALUES (2, 3, 'abc')). Thanks.

sprinkaan88 commented 1 year ago

Thank you so much, will give this a try and revert.

bimalkjha commented 1 year ago

@sprinkaan88 Have you checked it? Thanks.

sprinkaan88 commented 1 year ago

@bimalkjha apologies for the late reply, was on a short break. Yes we have tried it and it works perfectly, thanks so much.