Re: Resolving of reference/foreign keys - Mailing list pgsql-jdbc

From Fredrik Wendt
Subject Re: Resolving of reference/foreign keys
Date
Msg-id 3C97D84B.4090607@linux.se
Whole thread Raw
In response to Resolving of reference/foreign keys  ("Oliver Friedrich" <oliver@familie-friedrich.de>)
Responses Re: Resolving of reference/foreign keys
List 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




pgsql-jdbc by date:

Previous
From: Thomas O'Dowd
Date:
Subject: Re: Resolving of reference/foreign keys
Next
From: Thomas O'Dowd
Date:
Subject: Re: Resolving of reference/foreign keys