Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009

    Unanswered: Stored procedure return primary key of inserted row ?

    Hello guys, I want a stored procedure to return the primary key of the new record after it gets executed. I think it will be returned by OUT parameter in the procedure. But how to select the newly inserted row ID ? I don't want to use select MAX(row_id) as it is a multi user environment. Any procedure sample will be appreciated.

    The row id Column is not an identity column. It uses a sequence for the key which gets generated via a trigger before insert on table.

    My platform is ISeries DB2 V5 R4. Thanks.

  2. #2
    Join Date
    Feb 2008
    If you upgraded to DB2 for i Version 6 Release 1, you would be able to use data-change-table-reference.

    SELECT row_id FROM FINAL TABLE ( INSERT statement );

    But, I don't know anyway for DB2 for i5/OS Version 5 Release 4.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts