Skip site navigation (1) Skip section navigation (2)

reference constraint creation problem

From: kmh496 <kmh496(at)kornet(dot)net>
To: Postgres novice mailing list <pgsql-novice(at)postgresql(dot)org>
Subject: reference constraint creation problem
Date: 2006-06-15 14:18:58
Message-ID: (view raw or flat)
Lists: 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
    "qp_qualchoice_goodchoice_constraint_table_pkey" PRIMARY KEY, btree

mod=# select * from qp_qualchoice_goodchoice_constraint_table;
(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.....


<a href="">who am I?</a>.


pgsql-novice by date

Next:From: A. KretschmerDate: 2006-06-15 14:24:12
Subject: Re: reference constraint creation problem
Previous:From: Alex du PlessisDate: 2006-06-15 13:52:24
Subject: Re: functions returning sets

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group