I'm trying to log a version id for each insert into the target table. Each insert may contain multiple rows. For each insert, I want to assign a unique numeric id to a specific column. What exact code may help me with that?
I've made a simple numeric sequence with INCREMENT_BY = 1. I've tried to solve my task with a single trigger which will increment my version sequence and apply it to the version column. But, according to Oracle documentation - each trigger must either operate on row level or statement level. So I came to the conclusion that I need at least 2 triggers: one to increment version sequence and another one to apply it to rows that are being inserted.
I've made multiple versions of the statement level trigger to increment my sequence, but my syntax seems to be incorrect. Here is one of the examples:
create or replace TRIGGER my_trigger
AFTER INSERT ON my_table
BEGIN
my_sequence.NEXTVAL;
END;
This code shoots out PLS-00313: "NEXTVAL" not declared in this scope. I've also tried to use "NEXTVAL" inside "SELECT" statement, but it also was fruitless. What am I missing?