Re: Resolving of reference/foreign keys

From: Fredrik Wendt <fredrik(dot)wendt(at)linux(dot)se>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Resolving of reference/foreign keys
Date: 2002-03-20 00:31:07
Message-ID: 3C97D84B.4090607@linux.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Thomas O'Dowd wrote:

> [...]
> I've set ON DELETE to NO ACTION which means that if you delete a row
> from table a which is a FK in table b, the delete will fail unless you
> also delete the row in table b. I believe this is what you're looking
> for.
>
> You don't need to write any special code then to test or count
> references etc. Postgresql does it all for you. Check out the
> docs for more info.

Just a quick one: This deletion, must it be done in (1) one statement,
or can the delete operation be approved if (2) multiple delete
statements are issued within a transaction?

(1) DELETE FROM A, B WHERE B.table_A_ID = A.ID AND bla1 bla2

(2) BEGIN WORK
DELETE FROM A WHERE bla1
DELETE FROM B WHERE bla2
COMMIT

Are the above examples just rubbish, i.e. there are never any actual
cases where (2) can not be written as (1)?

/
Fredrik Wendt

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas O'Dowd 2002-03-20 00:35:50 Re: Resolving of reference/foreign keys
Previous Message Thomas O'Dowd 2002-03-20 00:07:51 Re: Resolving of reference/foreign keys