Re: Setting a row's value to the primary key after insert
Oh, jeez, I missed that part. Yes, you are caught on the horns of a dilemna. You can only update NEW in a BEFORE, and you don't have the autoincrement id until AFTER.
So you want to do this a bit differently:
delimiter //
CREATE TRIGGER calendar_insert_after AFTER INSERT
ON calendar
FOR EACH ROW
BEGIN
IF NEW.group_id IS NULL THEN
UPDATE calendar SET group_id = NEW.calendar_id WHERE calendar_id = NEW.calendar_id;
END IF
END; //
delimiter ;
Basically, you have to issue a new query to do it.
Subject
Views
Written By
Posted
3526
May 29, 2006 04:44AM
1953
May 29, 2006 04:40PM
2299
May 29, 2006 07:13PM
Re: Setting a row's value to the primary key after insert
2056
May 29, 2006 09:17PM
2296
May 29, 2006 09:27PM
2764
June 03, 2006 03:47PM
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.