reference constraint creation problem - Mailing list pgsql-novice

From kmh496
Subject reference constraint creation problem
Date
Msg-id 1150381138.7025.3.camel@var.sirfsup.com
Whole thread Raw
Responses Re: reference constraint creation problem  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
List pgsql-novice
hello everybody!!

i am trying to emulate mysql enum's by creating another table, putting
in the allowed values for the enum, and creating a REFERENCE CONSTRAINT
to it.  So, i have the created reference table:

mod=# \d qp_qualchoice_goodchoice_constraint_table;
Table "mod_schema.qp_qualchoice_goodchoice_constraint_table"
   Column   |         Type         | Modifiers
------------+----------------------+-----------
 goodChoice | character varying(3) | not null
Indexes:
    "qp_qualchoice_goodchoice_constraint_table_pkey" PRIMARY KEY, btree
("goodChoice")

mod=# select * from qp_qualchoice_goodchoice_constraint_table;
 goodChoice
------------
 n
 y
(2 rows)

mod=# \q


but when i try to do the following table which references it........

--
-- Table structure for table qp_qualchoice
--

CREATE TABLE qp_qualchoice (
  "qid" int2 NOT NULL default '0',
  "choiceid" int2 NOT NULL default '0',
 "goodChoice" varchar CONSTRAINT qp_qualchoice_goodChoice_constraint
REFERENCES qp_qualchoice_goodChoice_constraint_table (goodChoice)
default 'n',
  "choiceText" text NOT NULL,
  "addate" date default NULL,
  "moddate" date default NULL,
  "battery_id" varchar(15) default 'klpt4'
)  ;


i get this error:

psql:pg_sql.sql:44: ERROR:  column "goodchoice" referenced in foreign
key constraint does not exist


BUT THAT COLUMN EXISTS, so where is my mistake?

thanks to all.....

joseph.



--
<a href="http://openandout.com/~jcs/">who am I?</a>.






pgsql-novice by date:

Previous
From: Alex du Plessis
Date:
Subject: Re: functions returning sets
Next
From: "A. Kretschmer"
Date:
Subject: Re: reference constraint creation problem