Oracle connect by
declare
maxl number;
idnew number;
begin
for t in (select id from t2) loop
select max(level) ll into maxl from t1 start with id=t.id connect by prior pid=id;
select id into idnew from
(select level ll, id,pid from t1 start with id=t.id connect by prior pid=id)
where ll=maxl-1;
update t2 set id=idnew where id=t.id;
end loop;
commit;
end;[@more@]
maxl number;
idnew number;
begin
for t in (select id from t2) loop
select max(level) ll into maxl from t1 start with id=t.id connect by prior pid=id;
select id into idnew from
(select level ll, id,pid from t1 start with id=t.id connect by prior pid=id)
where ll=maxl-1;
update t2 set id=idnew where id=t.id;
end loop;
commit;
end;[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7312700/viewspace-1002636/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Laravel connect oracleLaravelOracle
- Oracle “CONNECT BY” 使用Oracle
- oracle connect by用法Oracle
- Oracle Start with ....Connect ByOracle
- START WITH and CONNECT BY in Oracle SQLOracleSQL
- oracle中start with connect by priorOracle
- oracle的connect by語句Oracle
- 【函式】Oracle “CONNECT BY” 使用函式Oracle
- Oracle Connect By Prior 詳解Oracle
- Linux Use ODBC Connect OracleLinuxOracle
- Oracle start with connect by PostgreSQL recursive cteOracleSQL
- Oracle Connect by 單行變多行Oracle
- Oracle Easy Connect Naming methodOracle
- PostgreSQL Oracle 相容性 - connect by 2SQLOracle
- WebMethod connect to Oracle10g RACWebOracle
- Oracle Transparent GateWay connect to MYSQL fix BUGOracleGatewayMySql
- Oracle禁止connect / as sysdba方式登入Oracle
- Unable to Connect to Database with Oracle Client Software for WindowsDatabaseOracleclientWindows
- Oracle的SYS_CONNECT_BY_PATH函式Oracle函式
- Oracle 樹操作(select…start with…connect by…prior)Oracle
- ORACLE 內建函式和connect by使用Oracle函式
- Oracle 9201下connect by的bugOracle
- 【PL/SQL】Oracle--樹的使用(Connect By)SQLOracle
- [轉載] Oracle:start with...connect by子句的用法Oracle
- Oracle中 connect by prior 遞迴演算法Oracle遞迴演算法
- Oracle中start with...connect by prior子句用法.docOracle
- Oracle ADG Heartbeat failed to connect to standby故障案例OracleAI
- Oracle中的Connect、session、process的區別OracleSession
- oracle 10.2.0.3對USER收回CONNECT及RESOURCEOracle
- oracle中 connect by prior 遞迴演算法 (轉)Oracle遞迴演算法
- oracle中connect by prior實現遞迴查詢Oracle遞迴
- How to use Form6i connect Oracle 10gORMOracle 10g
- Oracle內建角色connect與resource的許可權Oracle
- Oracle 樹查詢 效能最佳化紀實(start with, connect by)Oracle
- [轉載]使用Oracle樹形查詢應注意 - Start with / Connect byOracle
- start with ... connect by
- ORA-01788: CONNECT BY clause required in this query block For ORACLE 10GUIBloCOracle 10g
- ORACLE 樹形查詢(connect by...start with...)的應用(三)Oracle