0

我有以下 cte 查询,它适用于 11g 但不适用于 10g。如何使用 connect by 为 10g 编写相同的内容。不确定它是否可能..或者我需要将光标/while循环写入相同的内容。示例数据在这里Recursive sql server query 4

With Cte(Object_id,Parent_id) AS
(
SELECT 

       spl.object_id, 
       spl.folder_id
FROM   table1 spl 

WHERE  NOT EXISTS (SELECT 1 
                   FROM   table2 spt 
                   WHERE  spl.object_id = spt.object_id) 
       AND spl.staged = 0 

)
, recursive_cte (object_id,Parent_id,objectname2) AS 
(
    SELECT  
     object_id
    ,Parent_id
    ,CAST('' as varchar(201)) objectname2
     FROM Cte 
    UNION ALL
    SELECT 
    recursive_cte.object_id, 
    sf.parent_id, 
     CAST(sf.object_name as varchar(100)) || '\' || CAST(recursive_cte.objectname2 as varchar(100)) 
      FROM table3 sf
    INNER JOIN recursive_cte ON recursive_cte.Parent_id = sf.object_id
)
select * from recursive_cte;
4

0 回答 0