2 Replies Latest reply: Nov 17, 2008 2:28 PM by 669890 RSS

    Get RowID after INSERT

    669890
      Is there a way to get the RowID of a row after it has been inserted through ExecuteSQL? I know there's a way to do it in the Oracle .NET functions.
        • 1. Re: Get RowID after INSERT
          gdarling - oracle
          You could use the RETURNING clause with an anonymous block and a bind variable. For example:

          SQL> var v1 varchar2(4000);
          SQL> begin
          2 insert into emp (empno) values(1112) returning rowid into :v1;
          3 end;
          4 /

          PL/SQL procedure successfully completed.

          SQL> print v1;

          V1
          -----------------------------------------------------------------------------

          AAAQ+jAAEAAAAAeAAO

          Hope it helps,
          Greg
          • 2. Re: Get RowID after INSERT
            669890
            That wasn't exactly what I wanted to do, but it was close. I ended up using the RETURNING clause with an OParameter so I could use the rowID outside of the database.