I have an Oracle 12c database with a table containing an identity column:
CREATE TABLE foo (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
bar NUMBER
)
Now I want to insert into a table using PL / SQL. Since in practice the table has many columns, I use %ROWTYPE:
DECLARE
x foo%ROWTYPE;
BEGIN
x.bar := 3;
INSERT INTO foo VALUES x;
END;
However, this gives me this error:
ORA-32795: cannot be inserted into the generated identity column
ORA-06512: in row 5
Since it reads the code very well and supports it, I do not want to stop using it %ROWTYPE. Since under no circumstances do I want to allow anything other than an automatically generated identifier, I do not want to raise the restriction GENERATED ALWAYS.
, %ROWTYPE GENERATED BY DEFAULT ON NULL. ?