Re: SQL statement for Deleting

From: Ken Johnson <ken.johnson_at_mail.tapestry.com>
Date: 1996/07/25
Message-ID: <31F82C10.7147_at_mail.tapestry.com>#1/1


Mikko Rusama wrote:
>
> 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 isn't a SQL statement that you can use when deleting the orders for a give user when you delete it.

However, you can use the CASCADE option on your foreign key to have it always do this whenever a user record is deleted.

so you would use

   ... rest of statement ...
   foreign key(login) references users (num) ON DELETE CASCADE

instead of:

   ...
   foreign key(login) references users (num)

-- 
-------------------------------------------------
Ken Johnson -  Senior Technical Consultant
Tapestry Computing, Inc. http://www.tapestry.com
Received on Thu Jul 25 1996 - 00:00:00 CEST

Original text of this message