From: | Howie <caffeine(at)toodarkpark(dot)org> |
---|---|
To: | Mark Dalphin <mdalphin(at)amgen(dot)com> |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] Anyone recognise this error from PL/pgSQL? |
Date: | 1999-08-14 03:07:00 |
Message-ID: | Pine.LNX.3.96.990814030140.8919k-100000@rabies.toodarkpark.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, 13 Aug 1999, Mark Dalphin wrote:
> Hi,
>
> I'm trying my first PL/pgSQL code to trap foreign key errors. Before
> inserting into the table "Exon", I wish to be sure that a foreign key,
> 'zhvtID', exists in the table 'zhvt'. Sounds simple...
erm, why not use refint's check_(primary|foreign)_key() functions to
handle this ?
-- referential integrity: cascade deletes from zhvt to exon based on zhvtID
create trigger zhvt_zhvtID_trig
before delete or update on zhvt
for each row
execute procedure check_foreign_key ('1', 'cascade', 'zhvtID', 'exon',
'zhvtID' );
-- referential integrity: exon.zhvtid must exist in zhvt
create trigger exon_zhvtid_fk
before insert or update on exon
for each row
execute procedure check_primary_key( 'zhvtid', 'zhvt', 'zhvtid' );
> [SNIP]
---
Howie <caffeine(at)toodarkpark(dot)org> URL: http://www.toodarkpark.org
"The distance between insanity and genius is measured only by success."
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Olivier | 1999-08-14 04:05:24 | new.oid not working inside rule [repost] |
Previous Message | Mark Dalphin | 1999-08-14 01:05:17 | Anyone recognise this error from PL/pgSQL? |