Re: explicit cast error

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: explicit cast error
Дата
Msg-id 20020705211030.M1057-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на explicit cast error  (Lynn David Newton <lynn.newton@cox.net>)
Ответы Re: explicit cast error  (Lynn David Newton <lynn.newton@cox.net>)
Список 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 по дате отправления:

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Re: I am being interviewed by OReilly
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: I am being interviewed by OReilly