Published on InterSystems Developer Community (https://community.intersystems.com)

Home > How to get the insert ID in SQL?

Question
Nicola Sartore · Nov 4, 2021

How to get the insert ID in SQL?

I want to INSERT a record in a database using JDBC in  OBJECTSCRIPT. At the same time, I want to obtain the insert ID. Is there a way to achieve this using the SQL Outbound adapter?

My code is something like this now:


Property Adapter As EnsLib.SQL.OutboundAdapter;

set sql = " INSERT INTO Prenotazioni_CUP "_
                  " (ID, cf
                  " VALUES (SEQTAB.NextVal, ?) "
set status = ..Adapter.ExecuteUpdate(.rs, sql, pRequest.cfAssistito)

#JDBC #SQL #InterSystems IRIS
Product version: IRIS 2021.1

Source URL:https://community.intersystems.com/post/how-get-insert-id-sql