Pete Freitag Pete Freitag

Triggers in MySQL 5


Peter Gulutzan shows a sneak peak of Trigger support in MySQL 5 alpha in his article MySQL Triggers Tryout on O'Reilly OnLamp.

Like this? Follow me ↯

Triggers in MySQL 5 was first published on February 04, 2005.


You sent updating in MySQL 5.x
, Documentation in MySQL all version
, Syntax Trigger and Path Downlaod Graphic MySQL 5.x
by Pheath Rithy on 08/05/2005 at 12:22:56 AM UTC
before insert on comment
for each row
@maxid int;
@mon int(2);
@yr varchar(4);
@finyr varchar(10);
set mon:=to_number(to_char(:new.dt,'mm'));
set yr:=to_char(:new.dt,'yy');
if mon>=4 then
set finyr:=trim(yr)||'-'||trim(to_char(to_number(yr)+1,'00'));
set finyr:=to_char(to_number(yr)-1)||'-'||yr;
end if;
select max(comnocode) into maxid from comment;
if maxid is null then
set :new.compno:=1;
set :new.comnocode:=finyr||'1';
set :new.compno:=maxid+1;
set :new.comnocode:='w'||trim(finyr)||'/'||trim(to_char(maxid+1,'00'));
end if;

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER tr_id
before insert on comment
for each row
set @maxid int' at line 1
by Naveen Tripathi on 04/09/2007 at 1:26:39 AM UTC
The only host I found so far to support mysql triggers on shared packages is at I hope more will come. This is probably because hosting providers wait for plesk or cpanel to support such versions of PHP/MySql and those two are moving slower than anything else. PHP 5.2.9 came out recently and a lot of bugs were fixed yet nor cpanel or plesk supports this version. Mysql releases 5.4 soon so triggers will no longer need the super user privilege to be added, but, as always, how much time will the control panels need to support it?
by Jose Luis on 08/21/2009 at 12:40:54 PM UTC