Re: [SQL] Problem with subquery in CHECK constraint.

2000-06-09 Thread Niall Smart
Hiroshi Inoue wrote: > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > > Behalf Of Niall Smart > > > > CONSTRAINT TYPE_CD_OK CHECK ( > > EXISTS (SELECT 1 FROM XREF WHERE > > XREF_GROUP = 'CUST_TYPE' AND > > XREF_CD = TYPE_CD) > > ) > > > >

Re: [SQL] Problem with subquery in CHECK constraint.

2000-06-08 Thread Stephan Szabo
> CONSTRAINT TYPE_CD_OK CHECK ( > EXISTS (SELECT 1 FROM XREF WHERE > XREF_GROUP = 'CUST_TYPE' AND > XREF_CD = TYPE_CD) > ) > > > > There seems to be more serious problems. > > 1) The constraint is not only for the defined table but also for referenced > > tables in the subquery. > > I don't un

RE: [SQL] Problem with subquery in CHECK constraint.

2000-06-08 Thread Hiroshi Inoue
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of Niall Smart > > > CONSTRAINT TYPE_CD_OK CHECK ( > EXISTS (SELECT 1 FROM XREF WHERE > XREF_GROUP = 'CUST_TYPE' AND > XREF_CD = TYPE_CD) > ) > > > >

Re: [SQL] Problem with subquery in CHECK constraint.

2000-06-08 Thread Niall Smart
CONSTRAINT TYPE_CD_OK CHECK ( EXISTS (SELECT 1 FROM XREF WHERE XREF_GROUP = 'CUST_TYPE' AND XREF_CD = TYPE_CD) ) > There seems to be more serious problems. > 1) The constraint is not only for the defined table but also for referenced >

RE: [SQL] Problem with subquery in CHECK constraint.

2000-06-07 Thread Hiroshi Inoue
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf > Of Tom Lane > > Niall Smart <[EMAIL PROTECTED]> writes: > > However when trying to insert into CUST I get the following error: > > ERROR: ExecEvalExpr: unknown expression type 108 > > Is this a bu

Re: [SQL] Problem with subquery in CHECK constraint.

2000-06-07 Thread Tom Lane
Niall Smart <[EMAIL PROTECTED]> writes: > However when trying to insert into CUST I get the following error: > ERROR: ExecEvalExpr: unknown expression type 108 > Is this a bug in PostGreSQL? Yup. Looks like the subquery is not getting expanded into a subplan. Could be a little messy to

[SQL] Problem with subquery in CHECK constraint.

2000-06-07 Thread Niall Smart
Hi, I'm using a general lookup table defined as following to avoid a proliferation of lookup tables: CREATE TABLE XREF ( XREF_GROUP VARCHAR(12) NOT NULL, XREF_CD VARCHAR(8) NOT NULL, XREF_VALUE VARCHAR(128), PRIMARY KEY (XREF_GROUP, XRE