Re: explicit cast error - Mailing list pgsql-general

From Lynn David Newton
Subject Re: explicit cast error
Date
Msg-id 15655.16072.940886.47043@bela.interhack.net
Whole thread Raw
In response to Re: explicit cast error  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
  > ...>
  >> foreign key (dset) references datasets

  Stephan> In abc, you've got a text field and in def
  Stephan> it's refrencing the primary key which is an
  Stephan> int. That's not allowed. If you were running
  Stephan> 7.2 it would have errored when you tried to
  Stephan> make the table. Perhaps you mean for
  Stephan> abc(dlab) to reference def(dlab) in which
  Stephan> case the constraint should read:

  Stephan>  foreign key(dlab) refrences def(dlab)

Ack! Of course, of course, of course ...

My problem is now solved. Having close to zero
experience, and having extrapolated syntax for the
foreign key statement from an example full of foos and
ellipses, I assumed that the argument to 'references'
was simplay a table name and that it would look for a
column by the same *name* as the one referred to in the
calling table. I now see that doesn't make a lot of
sense, and that the actual field name in the other
table needs to be specified, even if it's the same
name, unless the default primary key is intended.

I would have eventually discovered that, if I'd read
only another 5-600 pages of manual.

Thank you very much.

--
Lynn David Newton
Phoenix, AZ



pgsql-general by date:

Previous
From: Hans-Juergen Schoenig
Date:
Subject: PostgreSQL doesn't use indexes even is enable_seqscan = off
Next
From: michael_walzl@yahoo.de (Michael Walzl)
Date:
Subject: Null in the where-clause