Hello,
i was wondering how to make automatic numbering of primary key without using sequence when "on" insert.
At the moment i am using trigger:
TRIGGER "scott"."do_numbers" BEFORE INSERT ON "scott"."test"
REFERENCING NEW AS NEW FOR EACH ROW
declare
pragma autonomous_transaction;
begin
SELECT
nvl(MAX(ID),0)+1
INTO :NEW.ID
FROM test;
commit;
END;
the above trigger works when i am inserting row by row. But now i tried to insert 300 rows at once. Here insert fails ... i think there should be commit after each insert (thats what i think).
Can someone explain it to me how can this "automatic" numbering can be done when inserting large number or rows from one table to another at once?
thank you!