Reputation: 986
So I have the following table:
CREATE TABLE car (
id NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY,
(...)
PRIMARY KEY (ID)
);
Then I've added a new column:
CREATE SEQUENCE car_sequence START WITH 1;
ALTER TABLE car ADD id_internal NUMBER DEFAULT car_sequence.nextval NOT NULL;
How can I force auto increment for id_internal
(on insert) based on the next value from the car_sequence
? Is a trigger the only way out here ?
Upvotes: 1
Views: 727
Reputation: 191455
when I try to insert a new row I am getting:
ORA-01400: cannot insert NULL into ("car"."id_internal")
This seems to be bug 18110491, which affects 12.1.0.1 and 12.1.0.2. It's reported as fixed in the October 2017 PSU (and in 12cR2), so - assuming you have a support contract, without which you won't be able to see the bug report anyway - you can apply that (or a later one). This is working fine for me in my 12cR1 system, with a more recent PSU.
Upvotes: 2