ORACLE 存储过程实战
--定义获取部门ID的函数 create or replace function Get_Dept_Id(in_Dept_name in varchar2) return integer as v_dept_id integer := 1; begin sELECT dept_id into v_dept_id FROM dict_depts WHERE DEPT_NAME = in_Dept_name; return v_dept_id; exception when no_data_found then v_dept_id := 1; return v_dept_id; when others then v_dept_id := 1200; --糯扎渡项目部将返回2条记录,在此处捕获并重新赋值 return v_dept_id; end Get_Dept_Id; --定义获取单位ID的函数 create or replace function Get_Unit_Id(in_unit_name in varchar2) return integer as v_unit_id integer := 1; begin SELECT id into v_unit_id FROM ins_unit_dict WHERE NAME = in_unit_name; return v_unit