Re: SQL statement for Deleting

From: Sylvan Creach <sc00802_at_po1.cobe.com>
Date: 1996/07/26
Message-ID: <4t9e7f$ord_at_news-2.csn.net>#1/1


>I have created two databases USERS and ORDER:
>
>USERS have the following tables:
>login , primary key
>fullname
>num
>
>and the ORDER has:
>login
>orderno
>where foreign key(login) references users
>
>So ORDER is dependent on the USERS database
>When I try to delete from the USERS database user which exists also in
>the HOBBBY, error message : ORA-02292: integrity constraint violated -
>child record found.
>
>So I have to delete that particular user from the HOBBY database in
>order to delete it from the USERS database.
>
>Is there SQL statement that also deletes particular user from all the
>child databases.
>
>Thanks for help!

There is no Delete statement although you could write a trigger to do what you want. But I would just change the FK constraint to cascade delete.

EXAMPLE: atler table users drop constriant FK_NAME;

ALTER TABLE ORDER ADD (

      CONSTRAINT ORDER_LOGIN_FK
      FOREIGN KEY (
       LOGIN)
        REFERENCES USERS (
       LOGIN)
        ON DELETE CASCADE

);

Hope this is what you wanted.

Sylvan Creach
Oracle DBA
Cobe Labs, Lakewood CO Received on Fri Jul 26 1996 - 00:00:00 CEST

Original text of this message