title: How to get last ID from oracle database using SQL command?
body: <p>Is there a mechanism to get last inserted ID in Oracle 12c Enterprise edition by using SQL command?
  In DB2 world, I would use:</p>
  
  <pre><code>SELECT IDENTITY_VAL_LOCAL() AS IDENTITY FROM SYSIBM.SYSDUMMY1
  </code></pre>
  
  <p>This would get me the last generated ID from current connection (session). This would mean that no matter if other inserts occur from other users (or same user but in different session) I would get the latest ID only from current session.</p>
  
  <p>The only answer I could find for Oracle was the one using anonymous block.</p>
  
  <pre><code>DECLARE
      V_ID NUMBER;
  BEGIN
      INSERT INTO OBJECT_EXAMPLE(NAME) VALUES ('Some name') returning ID into V_ID;
      DBMS_OUTPUT.put_line(V_ID);
  END;
  </code></pre>
  
  <p>However, this does not return result set. Since I'm using IBM BPM product I cannot define output parameter when executing anonymous block (I get "OUT parameters are only valid when used with a call operation"). Also, I cannot get "output" section like in DBeaver (I get empty record).</p>
  
  <p>So what I really need is:</p>
  
  <ul>
  <li>something that can insert a row into a table and get the latest ID form that table (or latest generated id from session) but only for that opened connection
  or</li>
  <li>something that acts like select but also does the insert</li>
  </ul>