Rich Shepard wrote:
For some of the tables I have foreign key triggers that apply to
INSERT,
UPDATE, and DELETE. When I create the table, do I explicitly name each
one
as an table constraint?
Example, I have three foreign key triggers, fki_comp_cat, fku_comp_cat,
and fkd_comp_cat that ensure that records in the 'component' table
match a
record in the 'category' table, and that if an attempt is made to
delete a
category while there are component rows that reference it, the process
aborts. So, do I write the ddl as:
create table component(comp_id integer primary key, comp_cat text,
comp_name
text, CONSTRAINT fki_comp_cat, fku_comp_cat, fkd_comp_cat);
I don't see this in Mike Owens' book.
TIA,
Rich
Rich,
The table must exist before the triggers can be created. The triggers
are associated with the table by naming the table in the trigger's
create statement, not by naming the trigger in the table's create statement.
create table component(comp_id integer primary key, comp_cat text,
comp_name text);
create trigger fki_comp after insert on component begin ... end;
create trigger fku_comp after update on component begin ... end;
HTH
Dennis Cote
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------