在同一表中寻找父类记录。 

 --路径级数

  1. select count(*)+1 into v_data from css.css_organizaioninfo t  
  2.           start with                         -- start with 是递归入口  
  3.           t.org_id = v_record.org_id         -- 指明入口条件              
  4.           connect by prior                   -- prior 前序遍历 ;不写,默认不递归查询  
  5.           tt.parter = t.org_id; 
  6.    param_path_level :v_data;               -- 级联条件(通过那个字段相连) 

 
--路径值 
 
  1. create or replace function f_find_father(p_value VARCHAR2) return VARCHAR2 is 
  2.      v_str VARCHAR2(60) := p_value; 
  3.      procedure p_get_father_str(p_son in varchar2,p_str in out varchar2) as 
  4.      begin 
  5.           for i in(select parter from css.css_organizaioninfo where org_id = p_son and parter != org_id) loop 
  6.             if instr(p_str ||'_','_'||i.parter ||'_') = 0 then 
  7.               p_str := i.parter || '_' ||p_str; 
  8.               p_get_father_str(i.parter,p_str); 
  9.             end if; 
  10.           end loop; 
  11.      end
  12.      begin 
  13.        p_get_father_str(p_value,v_str); 
          return v_str;
        end;