MySQL Forums
Forum List  »  Triggers

why a before trigger cannot modify new variables ?
Posted by: jean-claude jouffre
Date: April 20, 2006 09:38AM

hello,

1) when inserting a new record, I want put a particular value in a column, whatever value has been filled by the application ; so I created an AFTER INSERT TRIGGER whith the instruction :
SET NEW.MYCOL = MYVALUE;
but when I want to compile the trigger, I obtain this error message :
ERROR 1362: Updating of new row is not allowed in after trigger

I don't understand why it's not allowed

2) if I modify the trigger as a BEFORE INSERT TRIGGER, the column value for all records is leaded by the trigger and not by the application

it seemed to me that the behaviour would be :
- the application executes an insert
- the before trigger starts (and can put some default values for columns)
- the column values choosen by the application are inserted
- the after trigger starts (and can modify the column values)
is it correct or not ?

best regards,
jean-claude jouffre

p.s. : I run a 5.0.15 MySQL server

Options: ReplyQuote


Subject
Views
Written By
Posted
why a before trigger cannot modify new variables ?
7707
April 20, 2006 09:38AM


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.