Home » SQL & PL/SQL » SQL & PL/SQL » delete hierarchical data
delete hierarchical data [message #280125] Mon, 12 November 2007 10:17 Go to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
using start with connect by I can query hierarchical data , but is there a way to delete hierarchical data using one query ?
Re: delete hierarchical data [message #280139 is a reply to message #280125] Mon, 12 November 2007 10:59 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes.
SQL> select level, empno, ename
  2  from emp
  3  connect by prior empno = mgr
  4  start with empno = 7566
  5  /
     LEVEL      EMPNO ENAME
---------- ---------- ----------
         1       7566 JONES
         2       7788 SCOTT
         3       7876 ADAMS
         2       7902 FORD
         3       7369 SMITH

5 rows selected.

SQL> delete emp where rowid in 
  2  
SQL> .
SQL> delete emp where rowid in (
  2    select rowid
  3    from emp
  4    connect by prior empno = mgr
  5    start with empno = 7566
  6  );

5 rows deleted.

Regards
Michel
Previous Topic: Should a table have result of calculated fields?
Next Topic: User privilege for another user's specific schema
Goto Forum:
  


Current Time: Sat Dec 10 13:09:45 CST 2016

Total time taken to generate the page: 0.08260 seconds