Re: foreign key constraints, cannot delete

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Josh Close <narshe(at)gmail(dot)com>
Cc: POSTGRES <pgsql-general(at)postgresql(dot)org>
Subject: Re: foreign key constraints, cannot delete
Date: 2004-10-08 21:15:24
Message-ID: 20041008211524.GE9892@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You havn't posted the exact error message. You'll have to if you want
people to properly explain what's going on...

On Fri, Oct 08, 2004 at 04:07:43PM -0500, Josh Close wrote:
> How can a delete rows from a table that has foreign key constraints?
> Here is how I have it set up.
>
> I have 2 tables, tableA has fields and id's and tableB has fields that
> reference tableA's id's. I'm not able to do this
>
> BEGIN TRANSACTION;
>
> DELETE FROM tableB
> WHERE tableAid = 5;
>
> DELETE FROM tableA
> WHERE id = 5;
>
> COMMIT TRANSATION;
>
> Even though I delete everything from tableB that references tableA, I
> can't delete the field from tableA.
>
> Is this because of the begin and commit? Do I need to commit after each delete?
>
> The only problem with commiting after each is, if one fails for some
> reason, I need it to rollback.
>
>
> -Josh
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josh Close 2004-10-08 21:21:01 Re: foreign key constraints, cannot delete
Previous Message Josh Close 2004-10-08 21:07:43 foreign key constraints, cannot delete