From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: Looking for some help with cascading updates...
Date: Tue, 18 Apr 2006 20:31:01 +0200
Message-ID: <20060418183101.GA31339@KanotixBox> (raw)
In-Reply-To: <647d31c20604181119m43ba3c7ay3d467dd9446a6fd8@mail.gmail.com>
References: <647d31c20604181119m43ba3c7ay3d467dd9446a6fd8@mail.gmail.com>
Mark True <darfoo@gmail.com> schrieb:
>
> Here is the question:
>
> I have a situation where I need to create triggers to cascade an insert
> operation to many tables to maintain foreign key constraints.
>
> So at a high level
>
> INSERT INTO myTable (Name, Address, Zip) VALUES ('Mark', '3 Dingle St.',
> '01832')
>
> myTable has a relation to two other tables, which contain Zip and Address.
> Before I insert into myTable I want to:
>
> Check if '3 Dingle St.' exists in table Address, if not insert it
> Check if '01832' exists in table Zip and if not insert it
For such task i write a function (plpgsql). This obtains all parameters,
do the checks and insert into the other tables and the table with the fk
constraints.
HTH, Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknow)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: akretschmer@spamfence.net
Subject: Re: Looking for some help with cascading updates...
In-Reply-To: <20060418183101.GA31339@KanotixBox>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox