I'm really new to pl/sql. I'm trying to do a Trigger like this one (adr = after delete row) but it seems that I can't use ALTER SEQUENCE. Is this the right way of decrementing after a row is deleted or should I use a procedure?
CREATE OR REPLACE TRIGGER adr_trg AFTER DELETE ON table FOR EACH ROW BEGIN ALTER SEQUENCE table_seq INCREMENT BY -1; END;
Sequence I'm using:
CREATE SEQUENCE table_seq INCREMENT BY 1 START WITH 1;
Trigger I'm using:
CREATE OR REPLACE TRIGGER bir_trg BEFORE INSERT ON table FOR EACH ROW BEGIN IF :new.id IS NULL THEN :new.id := table_seq.nextval; END IF; END bir_trg;