From: | JohnC(at)firstlight(dot)com |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Referential Integrity Problems |
Date: | 2000-04-24 15:13:18 |
Message-ID: | OFDE797B57.555F3E55-ON852568CB.00524B09@firstlight.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm rather new to Postgresql, but hope someone here can help me out. Even
though I am specifying foreign and primary keys in my tables as I create
them, the foreign key options, such as CASCADE and NO ACTION, don't seem to
be working. I am allowed to change primary keys with no effect on the
foreign keys and with no error messages generated. I am using PHP3 and
postgresql 6.5.3 on Linux. I have tried using Bruce Momijian's example
code verbatim, and still didn't seem to have any kind of foreign key
constraints operating. Is this a result of some kind of
installation/configuration problem? Below are sections of the PHP Code I
am using to try Bruce's examples, though I don't run this all at once ( I
ran it exactly in the order in which Bruce gave it):
$connection = pg_connect("dbname=intranet user=intranet port=5432");
pg_exec($connection, "CREATE TABLE primarytest (col INTEGER PRIMARY KEY)");
pg_exec($connection, "CREATE TABLE foreigntest (col2 INTEGER REFERENCES
primarytest ON UPDATE CASCADE ON DELETE NO ACTION)");
pg_exec($connection, "INSERT INTO primarytest VALUES(1)");
pg_exec($connection, "INSERT INTO foreigntest VALUES(1)");
$update = pg_exec($connection, "UPDATE primarytest SET col=2");
pg_exec($connection, "DELETE FROM primarytest");
$result = pg_exec($connection, "SELECT * FROM foreigntest");
print("<table border=1 cellpadding=2>\n");
for($i = 0; $i < pg_numrows($result); $i++)
{
$thisrow = pg_fetch_row($result,$i);
print
("<tr><td>$i</td><td>$thisrow[0]</td><td>$thisrow[1]</td></tr>\n");
}
print("</table>\n");
pg_freeresult($result);
Your help is greatly appreciated.
John Clayton
Knowledge Manager
Site Builder
First Light Communications
55 John St. 8th Floor
New York, NY 10038
(212) 766-2380 x222
From | Date | Subject | |
---|---|---|---|
Next Message | JohnC | 2000-04-24 15:49:12 | RE: Referential Integrity Problems |
Previous Message | davidb | 2000-04-24 14:56:18 | Re: Revisited: Transactions, insert unique. |