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.area=varea,;
  /* 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

Written By
May 03, 2020 07:42AM
Re: Need help creating mysql trigger
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.