Reputation: 285
I have a sequence like this
begin
if :new."ID" is null then
select to_number(sys_guid(),'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') into :new.id from dual;
end if;
is there a way to set the ID to be the next upcoming ID in the table?
For example:
if my current last row ID is 5
I want the new.id to be 6, so when the INSERT executes then it would have ID of 6
Upvotes: 2
Views: 94
Reputation: 16224
IDENTITY column is now available on Oracle 12c:
create table t1 (
id NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1),
info VARCHAR2(10)
);
Upvotes: 1