01.createorreplaceviewV_NP_CTREE_BSas
02.selectB.*from(
03.selectA.*, lag(A.column_id) over(partitionbyA.column_idorderby0 ) RK
04. from(select/*+choose */
05. t.*
06. fromnp_cms_column t
07. wheret.is_active ='1'
08. connectbypriort.column_id = t.parent_id
09. startwitht.column_idin(selectt.column_id
10. fromnp_cms_column_security t
11. wheret.subject_id ='mazj'
12. /*这里添加角色过滤*/
13. andt.action_1 ='1'))A) B
14. wherenotexists
15. (select0
16. from(selectdistinctd.column_id
17. fromnp_cms_column d
18. connectbypriord.column_id = d.parent_id
19. startwithd.column_idin
20. (selectt.column_id
21. fromnp_cms_column_security t
22. wheret.subject_id ='mazj'
23. /* 这里添加角色过滤*/
24. andt.action_1 ='0'
25. /* 排除有权限树下的非授权ID,既 Action_1=0的*/
26. andexists
27. (select0
28. from(selectdistinctd.column_id
29. fromnp_cms_column d
30. connectbypriord.column_id =
31. d.parent_id
32. startwithd.column_idin
33. (selectt.column_id
34. fromnp_cms_column_security t
35. wheret.subject_id =
36. 'mazj'
37. /*这里添加角色过滤*/
38. andt.action_1 ='1')) C1
39. whereC1.column_id = t.column_id))
40. andd.is_active ='1') C
41. whereC.column_id = B.column_idandB.RKisnull)andB.RKisnull
42.unionall
43.selectc.*, 0 RKfromnp_cms_column cwherec.parent_id = 0;