Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Delete question
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