MySQL Forums
Forum List  »  Triggers

Re: Need help creating mysql trigger
Posted by: Peter Brawley
Date: May 03, 2020 08:59AM

In a Before Insert Trigger on access you could write ...

declare vcountry, varea, vcity varchar(64);
select country,area,city into vcountry,varea,vcity
from ip_lookup
where ip_address between NEW.start_ip and NEW.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
  /* add code to log the missing ip in iplookup to an error table */
end if;

The manual page on Trigger syntax will make the use of NEW in that code clear.

Options: ReplyQuote


Subject
Views
Written By
Posted
1109
May 03, 2020 07:42AM
Re: Need help creating mysql trigger
475
May 03, 2020 08:59AM


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.