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
1613
May 03, 2020 07:42AM
Re: Need help creating mysql trigger
666
May 07, 2020 09:41AM
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.