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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Delete question

Re: SQL Delete question

From: Geoff White <whiteg_at_ccis.adisys.com.au>
Date: Tue, 15 Jun 1999 11:13:31 +0800
Message-ID: <3765C4DB.A072C006@ccis.adisys.com.au>


Bill Mann wrote:

> I'm trying to write a DELETE SQL statement that will delete all the
> records returned from a select command.
> I have tested the select command and it works, but I get compilation
> errors when I combine with Delete. Is there a better way to delete a
> number of records. I know I could use the WHERE clause in the DELETE,
> but I need to use START WITH and CONNECT, these are only available in
> the SELECT statement.
>
> DELETE FROM (SELECT name FROM table
> START WITH
> manager = (select manager from table where grade = 3)
> CONNECT BY
> PRIOR manager = level)
>
> Thanks again.
> Bill.

It seems to me that all you need is to tell SQL from which table you wish to delete.
ie:

DELETE FROM table
where name in (SELECT name FROM table
  START WITH
   manager = (select manager from table where grade = 3)   CONNECT BY
   PRIOR manager = level)

should do it.

HTH
Geoff Received on Mon Jun 14 1999 - 22:13:31 CDT

Original text of this message

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