From: Josh Berkus <josh@agliodbs.com>
To: sqllist <pgsql-sql@postgresql.org>
Subject: Re: [GENERAL] Foreign Keys Help Delete!
Date: Tue, 19 Sep 2000 17:08:27 -0700
Message-ID: <39C7FFFB.6A9A0A2B@agliodbs.com> (raw)
References: <000371abbd90c460_mailit@smtp.applink.net>
Mr. Covell,
> 2. When I try to update "routes" table, it updates.
Actually, what I'm curious about is this part. Most databases that
support foriegn keys will not allow you to modify them as long as a
relation exists referencing the key, on either the master or child side,
unless you are updating the child to NULL (if the column is nullable) or
a valid alternative forign key value.
If you have updated the child record so that no records reference the
master key value, that key value should be then updatable without
violating the Forign Key constraint. However, I have not had reason to
test this on 7.0.2.
This provides you with two approaches for updating BOTH hosts and routes
table:
1. a. Create new record with new key value in hosts table with the
desired value
b. Update the routes record to reference the new value
c. Delete the old record in the hosts table
2. a. Drop the Foriegn Key constraint
b. Update both the routes and hosts tables
c. Re-establish the foriegn key constraint
If either of these approaches doesn't work, you have a valid bug
report. COngratulations!
-Josh Berkus
--
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 436-9166
for law firms, small businesses fax 436-0137
and non-profit organizations. pager 338-4078
San Francisco
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com
Subject: Re: [GENERAL] Foreign Keys Help Delete!
In-Reply-To: <39C7FFFB.6A9A0A2B@agliodbs.com>
References: <000371abbd90c460_mailit@smtp.applink.net> <39C7FFFB.6A9A0A2B@agliodbs.com>
* 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