# Oracle: getting the new identity value after an insert (RETURNING clause or sequence CURRVAL)

**URL:** <https://forums.softvelocity.com/t/oracle-getting-the-new-identity-value-after-an-insert-returning-clause-or-sequence-currval/1264>\
**Category:** Knowledge Base\
**Tags:** unverified, database-drivers\
**Created:** [November 9, 2026, 1:55am UTC](https://forums.softvelocity.com/t/oracle-getting-the-new-identity-value-after-an-insert-returning-clause-or-sequence-currval/1264 "2026-11-09T01:55:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rzaunere](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rzaunere](https://forums.softvelocity.com/u/rzaunere)\
**Post date:** [November 9, 2026, 1:55am UTC](https://forums.softvelocity.com/t/oracle-getting-the-new-identity-value-after-an-insert-returning-clause-or-sequence-currval/1264/1 "2026-11-09T01:55:17Z")

</div>

**Applies to:** Clarion 6.3 (the poster's version) with Oracle; the answers were given as general Oracle practice.

**Problem**

A new Oracle user asked whether any special technique is needed to obtain the identity value of a newly inserted row, in order to prime the child rows.

**Solution**

1. Oracle has no identity column in the SQL Server sense; it uses sequences. The usual setup is a database trigger on insert that puts `My_seq.nextval` into the surrogate key column.
2. After the insert, read the value back with `My_seq.currval`. It is specific to the client's connection, so other users' inserts do not disturb it.
3. Alternative: Oracle's `returning` keyword on the insert. One poster switched between Oracle and MSSQL like this: `Insert into test (FileDesc1, FileDesc2, NullField) values (?,?,?) returning sysid into ?` for Oracle, and `... values (?,?,?);Select ?=Scope_Identity()` for SQL Server.
4. The poster found the pointers useful and located the ClarionMag articles mentioned in the thread.

**Caveats**

- The `returning` poster said he did not use the Clarion Oracle driver. The other poster doubted it would work with that driver: the receiving column would have to be a number type, and even then he was not sure.
- Nobody reported testing either way against the Clarion Oracle driver.

**Today (2026)**

The sequence-plus-trigger pattern is standard Oracle and likely still holds. Newer Oracle versions may add identity columns; not covered by the thread and not re-tested.

**Sources:** Greg F. (Dec 2006, the question), Jim K., Jon W. (Dec 2006) in softvelocity.clarion.databasedrivers.
