Re: Need help creating mysql trigger
Peter, I get an undeclared variable error using your latest code. I tried the following but it just sits there and does nothing in mysql shell:
mysql> DELIMITER //
mysql> CREATE TRIGGER access_ins BEFORE INSERT ON access
-> FOR EACH ROW begin
-> declare vcountry varchar(50);
-> declare varea varchar(50);
-> declare vcity varchar(50);
->
-> select country,area,city into vcountry,varea,vcity
-> from ip_lookup
-> where NEW.ADDRESS between ip_lookup.start_ip and ip_lookup.end_ip
-> limit 1;
-> if vcountry is not null then
-> set NEW.country=vcountry, NEW.area=varea, NEW.city=vcity;
-> else
-> set NEW.country='Unknown', NEW.area='Unknown', NEW.city=nknown';
'> end if;
'> END; //
'>
'> DELIMITER ;
'>
No errors are generated but nothing is happening.
Subject
Views
Written By
Posted
2303
May 03, 2020 07:42AM
1005
May 03, 2020 08:59AM
1031
May 03, 2020 03:29PM
1042
May 03, 2020 05:32PM
1265
May 03, 2020 06:25PM
1253
May 07, 2020 06:28AM
1061
May 07, 2020 09:41AM
Re: Need help creating mysql trigger
1013
May 09, 2020 09:14AM
1025
May 09, 2020 10:20AM
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.