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_trigbefore delete or update on zhvtfor each rowexecute procedure check_foreign_key ('1',
'cascade','zhvtID', 'exon',
'zhvtID' );
-- referential integrity: exon.zhvtid must exist in zhvt
create trigger exon_zhvtid_fkbefore insert or update on exonfor each rowexecute procedure check_primary_key( 'zhvtid',
'zhvt','zhvtid' );
> [SNIP]
---
Howie <caffeine@toodarkpark.org> URL: http://www.toodarkpark.org
"The distance between insanity and genius is measured only by success."