Re: [SQL] Parent table has not oid?

Lists: pgsql-phppgsql-sql
From: "Zhidian Du" <duzhidian(at)hotmail(dot)com>
To: pgsql-php(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, sszabo(at)megazone23(dot)bigpanda(dot)com
Subject: Parent table has not oid?
Date: 2002-11-10 06:04:05
Message-ID: F61oWoCaNCnFjtCEhgv00004919@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-php pgsql-sql

Dear All:

Please disregerd my last email.

I want to create a delete cascade in children tables. The primary key of
parent table is oid.

CREATE TABLE Link (
Protein_ID oid
CONSTRAINT one
REFERENCES Protein (oid)
ON DELETE CASCADE,
Link varchar(128)
);

Create child table is ok.

When I insert a record into this child table, it says
"ERROR: constraint one: table protein does not have an attribute oid"

Why?

Thanks.

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Zhidian Du" <duzhidian(at)hotmail(dot)com>
Cc: pgsql-php(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, sszabo(at)megazone23(dot)bigpanda(dot)com
Subject: Re: [SQL] Parent table has not oid?
Date: 2002-11-10 13:50:24
Message-ID: 8821.1036936224@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-php pgsql-sql

"Zhidian Du" <duzhidian(at)hotmail(dot)com> writes:
> CREATE TABLE Link (
> Protein_ID oid
> CONSTRAINT one
> REFERENCES Protein (oid)
> ON DELETE CASCADE,
> Link varchar(128)
> );
> When I insert a record into this child table, it says
> "ERROR: constraint one: table protein does not have an attribute oid"

How old is your Postgres?

IIRC, this was made to work in 7.2 or thereabouts.

Note that using OID as a foreign key is not really a good idea, because
it's problematic to dump and restore. You'd be better off with a serial
column as primary key.

regards, tom lane


From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Zhidian Du <duzhidian(at)hotmail(dot)com>
Cc: <pgsql-php(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] Parent table has not oid?
Date: 2002-11-12 17:12:39
Message-ID: Pine.LNX.4.33.0211121011440.24725-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-php pgsql-sql

On Sun, 10 Nov 2002, Tom Lane wrote:

> "Zhidian Du" <duzhidian(at)hotmail(dot)com> writes:
> > CREATE TABLE Link (
> > Protein_ID oid
> > CONSTRAINT one
> > REFERENCES Protein (oid)
> > ON DELETE CASCADE,
> > Link varchar(128)
> > );
> > When I insert a record into this child table, it says
> > "ERROR: constraint one: table protein does not have an attribute oid"
>
> How old is your Postgres?
>
> IIRC, this was made to work in 7.2 or thereabouts.
>
> Note that using OID as a foreign key is not really a good idea, because
> it's problematic to dump and restore. You'd be better off with a serial
> column as primary key.

Yeah, I found that out the hardway and spent a couple days rewriting an
app that had used OIDs in a way it really shouldn't have.

The only time I use OIDs now is to get rid of duplicate rows by hand or
such like that.