ORACLE 和 SQL 分别实现递归的方法
时间:2010-12-10 来源:钻石眼泪
Sql的CTE
WITH EMPLOYEE_LIST AS (
SELECT A.EMP_NO AS APPROVER_ID,1 AS SEQUENCE_NO,'实际需求方/DEPT MANAGER' AS APPROVER_ROLE,A.SUPERVISOR
FROM AM_EMPLOYEE A,FIN_APPROVE_MODEL B
WHERE B.FORM_TYPE='CT_BI' AND B.OU_CODE=@OU_CODE
AND A.EMP_NO= B.EMPLOYEE_NUMBER
AND A.EMP_NO=@EMP_NO
UNION ALL
SELECT A.EMP_NO AS APPROVER_ID,1 AS SEQUENCE_NO,'实际需求方/DEPT MANAGER' AS APPROVER_ROLE,A.SUPERVISOR
FROM AM_EMPLOYEE A,FIN_APPROVE_MODEL B,EMPLOYEE_LIST C
WHERE B.FORM_TYPE='CT_BI' AND B.OU_CODE=@OU_CODE
AND A.EMP_NO= B.EMPLOYEE_NUMBER
AND A.EMP_NO=C.SUPERVISOR
AND B.MAX_AMOUNT<=@MAX_AMOUNT
)
SELECT APPROVER_ID,SEQUENCE_NO,APPROVER_ROLE FROM EMPLOYEE_LIST
ORACLE
SELECT A.CATEGORY_ID, B.CATEGORY_NAME
FROM (SELECT A.CATEGORY_ID
FROM DCS_CATEGORY A
START WITH A.CATEGORY_ID = 1000124
CONNECT BY PRIOR A.CATEGORY_PID = A.CATEGORY_ID) A,
DCS_CATEGORY_TL B
WHERE A.CATEGORY_ID = B.CATEGORY_ID
AND B.LANGUAGE = 'zh-CN'