Re: Oracle Foreignkey: really it works?

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Sat, 14 Oct 2000 08:49:26 +0100
Message-ID: <971510777.8284.0.nnrp-10.9e984b29_at_news.demon.co.uk>


This is the documented behaviour, and
explained in the Concepts manual.

If you want to avoid the issue, then
declare the columns (flag, resource)
to be NOT NULL on the child table.

If they are declared as the PRIMARY KEY
on the parent table, then they will automatically be declared NOT NULL there; but if they are only declared as UNIQUE on the parent table, then you will have to add the NOT NULL
constraint there as well.

P.S. Please avoid cross-posting to multiple C.D.O. newsgroups when the question is
most appropriate to just one of them.

--

Jonathan Lewis
Yet another Oracle-related web site:  http://www.jlcomp.demon.co.uk

Antonio Sant wrote in message ...

>Excuse my bad English.
>
>I want to discuss with you this strange (?) behaviour.
>
>Suppose we have this tables
>
>Tab1
>ID NUMBER
>Flag Char(1)
>Resource Number
>
>Tab2
>Flag Char(1)
>Resource Number
>Desc Varcahr(200)
>
>with a foreing key from Tab2 to Tab1 defined as (flag,resource).
>
>If we submit this code
>
>Begin
> Insert into Tab1
> Values (1,'K',12);
>
> Insert into Tab2
> Values ('K',12,'Oracle test');
>
>END;
>
>It works great, but the same applay for the next:
>
>Begin
>
>Insert into Tab2
> ('K',NULL,'Oracle test');
>
>END;
>
>For Oracle the Foreing key relation hold!
>
>We are working with Oracle 7 version 7.4 On AIX, the same things seme to
>work in Oracle 8.0 on Sun!
>
>Is this a bug?
>
>Any suggestion?
>
>If needed I can post a more detailed version.
>
>Bye for now!
>
>
>
>
Received on Sat Oct 14 2000 - 09:49:26 CEST

Original text of this message