I would like to write a trigger which will be able to add sequence value to column value.
Example: Sequence value is 5 and column value in table is 45. Result after inserting new row should be 50.
Problem is that I dont know how to fetch value from the column and then add it to the sequence value in trigger code.
After using my trigger I am able to insert a new row which will create columns with value = 5.
CREATE SEQUENCE Adding_Seq
START WITH 5
INCREMENT BY 1;
CREATE OR REPLACE TRIGGER Adding_Trigger
BEFORE INSERT ON Table
FOR EACH ROW
BEGIN
SELECT Adding_Seq.nextval
INTO :new.Value
FROM dual;
END;
I tried to add some "+" in section SELECT or later in INTO with name of the column from table, but there were errors.
Is is possible to do something like this in trigger or not?
Thanks for you help!
This is really strange. But you can just use addition:
BEGIN
SELECT :new.Value + Adding_Seq.nextval INTO :new.Value
FROM dual;
END;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.