Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Can a constraint use a sql statement?
Doesn't make sense.
This is a so-called business-rule which you can resolve by
a) a trigger
b) inserting or updating a view with check option
Regards,
Sybrand Bakker, Oracle DBA
"Brian Tkatch" <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK> wrote in
message news:39e60d01.539274921_at_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 - 15:53:56 CDT
![]() |
![]() |