Syntax error in my trigger
Posted by:
Ilyass G
Date: August 08, 2011 05:12AM
Hello,
I am currently trying to create a trigger that assigns a
code (PK) to inserted rows. Since I need this for a Java program, I was thinking about inserting rows where
code is 0 and then using the trigger to give them a unique value.
e.g: INSERT INTO S values(0);
Unfortunately, my tries have been unsuccessful so far, as I either get a syntax error or an "unknown system variable 'code'". Here is what I have done so far:
CREATE TRIGGER codeset BEFORE INSERT ON S FOR EACH ROW
BEGIN
SET @max = (SELECT MAX(code) FROM S);
SET code = 1 + @max;
END;
Thank you for your help,
Subject
Views
Written By
Posted
Syntax error in my trigger
2536
August 08, 2011 05:12AM
989
August 08, 2011 06:12AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.