Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Can a constraint use a sql statement?

Can a constraint use a sql statement?

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Thu, 12 Oct 2000 19:17:21 GMT
Message-ID: <39e60d01.539274921@news.alt.net>

I want to add a constraint a to a table checking that its foriegn key refrences a record that has specific data in its record.

A
==

Id (Foriegn Key to B.Id)

B
==

Id (Primary Key)
Type (Foriegn Key to C.Id)

C
==

Id (Primary Key)
Name

The contraint would be on A.Id that B.Type = C.Id where C.Name = 'Data';

CHECK (

               A.Id IN
                 (SELECT Id FROM B WHERE Type IN
                   (SELECT Id FROM C WHERE Name = 'Data'))
                 )
             )


Does that make any sense? Is it possible to add?

Brian Received on Thu Oct 12 2000 - 14:17:21 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US