Referential integrity using constant in foreign key - Mailing list pgsql-general

From Andrus Moor
Subject Referential integrity using constant in foreign key
Date
Msg-id d21dtu$imu$1@news.hub.org
Whole thread Raw
Responses Re: Referential integrity using constant in foreign key
List 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.



pgsql-general by date:

Previous
From: Jeff Amiel
Date:
Subject: Persistent data per connection
Next
From: Dawid Kuroczko
Date:
Subject: Re: Delay INSERT