Referential integrity using constant in foreign key

From: "Andrus Moor" <eetasoft(at)online(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Referential integrity using constant in foreign key
Date: 2005-03-25 16:22:14
Message-ID: d21dtu$imu$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to create referential integrity constraints:

CREATE TABLE classifier (
category CHAR(1),
code CHAR(10),
PRIMARY KEY (category,code) );

-- code1 references to category 1,
-- code2 references to category 2 from classifier table.
CREATE TABLE info (
code1 CHAR(10),
code2 CHAR(10),
FOREIGN KEY ('1', category1) REFERENCES classifier,
FOREIGN KEY ('2', category2) REFERENCES classifier
);

Unfortunately, second CREATE TABLE causes error

ERROR: syntax error at or near "'1'" at character 171

Any idea how to implement referential integrity for info table ?
It seems that this is not possible in Postgres.

Andrus.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dawid Kuroczko 2005-03-25 16:29:09 Re: Delay INSERT
Previous Message Jeff Amiel 2005-03-25 16:15:13 Persistent data per connection