• 23. 根据公司查找底下的所有部门,根据部门找对应的公司


    /**

    *   公司下存在子公司,子公司下存在部门,部门下存在子部门

    *   公司下存在部门,部门下存在子部门

    *   根据公司找底下的所有部门:select * from lbOrganization where fun_findComOrgId(ID)=公司ID;

    *   根据部门对应的公司:select fun_findComOrgId(部门ID) from dual;

    */

    create or replace function fun_findComOrgId(--查询所属公司或集团的id
    p_orgid int--传人组织机构id
    )
    return int is

    v_flag int:=0;--所属公司或集团的id
    v_orgtype int;--组织机构类型变量,2为公司,3为部门
    v_orgid int;--存放输入的组织机构id,或查出的

    begin
    v_orgid:=p_orgid;

    while v_flag=0 loop
    select orgtype into v_orgtype from lborganization where id=v_orgid;
    if v_orgtype<=2 then
    v_flag:=v_orgid;--v_flag=所属公司id
    else
    v_flag:=0;
    end if;
    select fid into v_orgid from lborganization where id=v_orgid;

    end loop;

    return (v_flag);

    end;
    /

  • 相关阅读:
    Dapper的常用操作
    git下载慢的解决方案
    笔记
    第06组 Beta冲刺(3/5)
    第06组 Beta冲刺(2/5)
    第06组 Beta冲刺(1/5)
    第06组 Alpha事后诸葛亮
    第06组 Alpha冲刺(6/6)
    第06组 Alpha冲刺(5/6)
    第06组 Alpha冲刺(4/6)
  • 原文地址:https://www.cnblogs.com/zkx4213/p/5012265.html
Copyright © 2020-2023  润新知