Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Request help from SQL Gurus

Re: Request help from SQL Gurus

From: Brian Peasland <peasland_at_email.msn.com>
Date: Thu, 27 May 1999 18:20:11 -0500
Message-ID: <e7mm9fJq#GA.243@cpmsnbbsa02>

gthorne777_at_my-deja.com wrote in message <7ika2p$86l$1_at_nnrp1.deja.com>...
>Hi, we are running RDB7. I'm not an SQL expert by any means, so I need
>help with this statement. I have two tables. We'll call them TABLE1
>and TABLE2 for this example. I have rows in both tables that I want to
>delete based on a condition in TABLE1. For exaple, let's say TABLE1 has
>the following rows:
> DATE INTEGER
> BATCH_ID INTEGER
> DEST CHAR(8)
>
>and TABLE2 has the following rows:
> BATCH_ID INTEGER
> DEST CHAR(8)
> NAME CHAR(25)
> ADDR CHAR(50)
> ZIP CHAR(50)
> PHONE CHAR(15)
>
>I want to delete the records in TABLE1 before a certain date, and also
>delete the records in TABLE2 that have a corresponding BATCH_ID and
>DEST. What would be the easiest way to do this? I'm re-writing a

The easiest way would be to create a foriegn key for BATCH_ID in TABLE2 that refers to the BATCH_ID of TABLE1. When you do the delete from TABLE1, use the CASCADE option. This will automatically delete those records in TABLE2 with the same BATCH_ID.

HOpe that helps,
Brian Peasland
peasland_at_msn.com Received on Thu May 27 1999 - 18:20:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US