Sub Select inside Check ? - Mailing list pgsql-sql

From Rudi Starcevic
Subject Sub Select inside Check ?
Date
Msg-id 3E5B03B9.4070500@oasis.net.au
Whole thread Raw
Responses Re: Sub Select inside Check ?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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.



pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: indexing
Next
From: Stephan Szabo
Date:
Subject: Re: Problem with deferred referential integrity checks