Re: Need help creating mysql trigger
Sorry, I reversed new and ip_lookup ...
drop trigger if exists access_ins;
delimiter go
create trigger access_ins before insert on access for each row
begin
declare vcountry, varea, vcity varchar(64);
select country,area,city into vcountry,varea,vcity
from ip_lookup
where NEW.ip_address between ip_lookup.start_ip and ip_lookup.end_ip
limit 1; /* iplookup table might have multiple rows matching given range */
if vcountry is not null then
set NEW.country=vcountry, NEW.area=varea, NEW.city=vcity;
/* else ... code to handle error */
end if;
end;
go
delimiter ;
Subject
Views
Written By
Posted
2340
May 03, 2020 07:42AM
1016
May 03, 2020 08:59AM
1056
May 03, 2020 03:29PM
1001
May 03, 2020 04:26PM
1057
May 03, 2020 05:32PM
1368
May 03, 2020 06:25PM
1288
May 07, 2020 06:28AM
Re: Need help creating mysql trigger
1098
May 07, 2020 09:41AM
1028
May 09, 2020 09:14AM
1044
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.