Oracle到MS SQL查询转换 - 按先行和先前连接SYS_CONNECT_BY_PATH

时间:2015-05-19 10:06:51

标签: sql sql-server oracle

任何人都可以重新创建这个Oracle Query into MSSQL

select 
dtree.dataid, 
dtree.subtype, 
sys_connect_by_path( dtree2.name, ' : ') ||' : ' || dtree.name "Folder Path" 
from 
dtree, 
dtree dtree2 
where 
dtree.parentid = dtree2.dataid 
start with 
dtree.dataid = %1 
connect by prior 
dtree.dataid = dtree.parentid 
Order siblings by dtree.name asc

该查询适用于Open Text的Livelink ECM应用程序... DTREE表格包含父母&每个项目的子关系,到目前为止,我设法做的只是报告文件夹的内容&子文件夹使用: -

WITH DATAID AS (
SELECT DATAID
FROM DTREE
WHERE parentID = %1
), tree AS (
SELECT x.SubType, x.Name, x.ParentID, x.DATAID
FROM DTREE x
INNER JOIN DATAID ON x.DATAID = DATAID.DATAID
UNION ALL
SELECT y.SubType, y.Name, y.ParentID, y.DATAID
FROM DTREE y
INNER JOIN tree t ON y.ParentID = t.DATAID
)
SELECT ParentID, DATAID, Name, SubType
FROM tree

我需要构建完整的项目路径......

感谢您提供任何帮助!

0 个答案:

没有答案