Re: explicit cast error - Mailing list pgsql-general

From Stephan Szabo
Subject Re: explicit cast error
Date
Msg-id 20020705211030.M1057-100000@megazone23.bigpanda.com
Whole thread Raw
In response to explicit cast error  (Lynn David Newton <lynn.newton@cox.net>)
Responses Re: explicit cast error
List 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)




pgsql-general by date:

Previous
From: Rich Shepard
Date:
Subject: Re: I am being interviewed by OReilly
Next
From: "Marc G. Fournier"
Date:
Subject: Re: I am being interviewed by OReilly