Hi I am trying to set conditional row trigger in phpmyadmin as shown below
CREATE TRIGGER temptri After insert on contact
for each Row
when(New.Age>20)
begin
insert into updates(uName,uAge,uAddr) values(New.Name,New.Age,New.Addr);
END;
I had made delimiter changes but i am getting some error like
MySQL said:
#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 'when(New.Age>20)
begin
insert into updates(uName,uAge,uAddr) values(New.Name,N' at line 3
strange thing is if i take condition out trigger is working fine so in short where i should this condition check
conditional triggers in phpmyadmin
Moderator: General Moderators
-
piyushtiwari
- Forum Newbie
- Posts: 5
- Joined: Mon Nov 24, 2008 8:41 am
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: conditional triggers in phpmyadmin
HUMmmm never heard of WHEN in flow control! Anyways use "IF", do a google search or go through manual coz i feel like you will miss the THEN and END IF 
-
piyushtiwari
- Forum Newbie
- Posts: 5
- Joined: Mon Nov 24, 2008 8:41 am
Re: conditional triggers in phpmyadmin
that too is not working
CREATE TRIGGER temptri
After insert on contact
for each Row
if (new.Age> 100) then
begin
insert into updates(uName,uAddr) values(New.Name,New.Addr);
end;
ENDIF;
#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 '' at line 8
CREATE TRIGGER temptri
After insert on contact
for each Row
if (new.Age> 100) then
begin
insert into updates(uName,uAddr) values(New.Name,New.Addr);
end;
ENDIF;
#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 '' at line 8
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: conditional triggers in phpmyadmin
Code: Select all
CREATE TRIGGER temptri
After INSERT ON contact
FOR each Row
BEGIN
IF (new.Age> 100) THEN
INSERT INTO updates(uName,uAddr) VALUES(New.Name,New.Addr);
END IF;
END;
-
piyushtiwari
- Forum Newbie
- Posts: 5
- Joined: Mon Nov 24, 2008 8:41 am
Re: conditional triggers in phpmyadmin
thanks a lot it worked
