MySQL Forums
Forum List  »  Triggers

Re: Need help creating mysql trigger
Posted by: Larry Hale
Date: May 09, 2020 09:14AM

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.area=varea,;
-> else
-> set'Unknown', NEW.area='Unknown',';
'> end if;
'> END; //

No errors are generated but nothing is happening.

Options: ReplyQuote

Written By
May 03, 2020 07:42AM
Re: Need help creating mysql trigger
May 09, 2020 09:14AM

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.