Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
We know that we can access the Identity value using: values IDENTITY_VAL_LOCAL() into :IdentVal. This needs to be performed immediately following the Insert into....
But there is an alternative:
select Identity into :IdentVal from final table (insert into TABLE (field1, .......) Values (:Data, ......))
Obviously need to check sqlcode/sqlstate for success, but the entire insert and tell me what the value of the Identity field was is performed in a single sql action.
Where's the "Like" button on this thing.