Sub Select inside Check ?

From: Rudi Starcevic <rudi(at)oasis(dot)net(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: Sub Select inside Check ?
Date: 2003-02-25 05:48:41
Message-ID: 3E5B03B9.4070500@oasis.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I'm trying to create this table with a Check that fails.

I'm using 'Check' instead of 'References' due to poor db schema ( before
me .. )

Here is my error message:
ERROR: cannot use subselect in CHECK constraint expression

CREATE TABLE cp_retailers
(
ret_id serial PRIMARY KEY,
ret_name varchar(120) NOT NULL,
ret_address1 varchar(120),
ret_address2 varchar(120),
sub_id integer NOT NULL CHECK
( EXISTS
( SELECT sub_id FROM suburbs )
)
);

I guess that say's it all - no sub select's in Check or am I on the
wrong track ?

Thank you kindly
Regards
Rudi.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tambet Matiisen 2003-02-25 06:42:09 Re: good style?
Previous Message Edmund Lian 2003-02-25 03:44:02 Re: Denormalizing during select