Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: CUSTOM data integrity constraint
A copy of this was sent to Nandakumar <N.Kumar_at_rocketmail.com>
(if that email address didn't require changing)
On Tue, 24 Aug 1999 16:41:42 GMT, you wrote:
>Hi,
>
>There are two fields in a table which are of datatype varchar2.
>Say Field1, Field2.
>When Field1 is NON NULL, Field2 CAN'T be NULL.
>How could i impose this as a constraint to one of the fields?
>...
>I think this is achievable with INSERT trigger.
create table t
( f1 int,
f2 int,
check ( f1 is null or ( f1 is not null and f2 is not null ) )
)
/
if f1 is NULL, the data is OK
if f1 is not null then f2 must also be not null....
--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue Aug 24 1999 - 13:05:02 CDT