From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Lynn David Newton <lynn(dot)newton(at)cox(dot)net> |
Cc: | Thomas Lockhart <lockhart(at)fourpalms(dot)org>, Andrew Sullivan <andrew(at)libertyrms(dot)info>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Joe Conway <mail(at)joeconway(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: explicit cast error |
Date: | 2002-07-06 04:13:34 |
Message-ID: | 20020705211030.M1057-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 5 Jul 2002, Lynn David Newton wrote:
> --------------------- the tables ----------------------
> create table abc
> (
> c1 serial not null primary key,
> c2 smallint not null,
> lab text not null,
> dlab text not null,
> bdigits bigint null,
>
> foreign key (dlab) references def
> );
>
> create table def
> (
> defseq serial not null primary key,
> dlab text unique not null,
> dset text null,
> choices text null check (logos in ('','case1','case2', 'case3','case4')),
> l1 text null,
> l2 text null,
> l3 text null,
>
> foreign key (dset) references datasets
> );
> -------------------------------------------------------
>
> One person asked about the release. It's 7.1.3.
Yep, IIRC we didn't start doing at constraint definition
checks for type equivalence until 7.2, so...
The types for a foreign key must be comparable on both sides
In abc, you've got a text field and in def it's refrencing
the primary key which is an int. That's not allowed. If
you were running 7.2 it would have errored when you tried
to make the table. Perhaps you mean for abc(dlab) to
reference def(dlab) in which case the constraint should
read:
foreign key(dlab) refrences def(dlab)
From | Date | Subject | |
---|---|---|---|
Next Message | Marc G. Fournier | 2002-07-06 04:17:34 | Re: I am being interviewed by OReilly |
Previous Message | Lynn David Newton | 2002-07-06 03:35:19 | Re: explicit cast error |