First attempt at a trigger
Posted in 1997
I'm making my first attempt at a trigger.
I have a table called rest_zips with three fields (name, zip, area). I
have a second table called zip_areas (zip, area).
Whenever a record is inserted into rest_zips I want to look the zip
code up in zip_areas and insert the appropriate area into rest_zips.
I created the following trigger:
CREATE TRIGGER zip2areaINSERT ON rest_zip
REFERENCING NEW AS post_ins
FOR EACH ROW (INSERT INTO rest_zip (area) SELECT area FROM zip_areas
WHERE zip = post_ins.zip)
The trigger is created okay but when I try inserting something into
rest_zips as so:
insert into rest_zips (name, zip) values ("jason", "78746")
I get an error: 747: Table or column matches object referenced in
triggering statement.
Is there no way to have a trigger act on its own table?
--
Jason C. Bodnar
jason@cimedia.com
Internet Programmer
Cox Interactive Media