create or replace procedure ossbusiinfoimport
(ossbusiid in varchar2, reqid in varchar2, log_accept in varchar2, ele_key in varchar2, ele_val in varchar2)
is busiid pd_busi_instance_info.busi_id%type; --業務資訊id
classid or_req_info.class_id%type;
element_val pd_element_instance_info.element_value%type;
--帶引數游標
cursor query_z(log_acc pd_element_instance_info.loginaccept%type, b_id pd_element_instance_info.busi_id%type, e_id pd_element_instance_info.element_id%type)
is select element_value from pd_element_instance_info where loginaccept=log_acc and busi_id=b_id and element_id=e_id;
--帶引數游標
cursor query_m(log_acc pd_element_instance_mid.loginaccept%type, b_id pd_element_instance_mid.busi_id%type, e_id pd_element_instance_mid.element_id%type)
is select element_value from pd_element_instance_mid where loginaccept=log_acc and busi_id=b_id and element_id=e_id;
begin
--根據reqid查詢class_id
select class_id into classid from or_req_info where req_id=reqid and login_accept=log_accept;
--變更業務型別,更新中間表
if(classid='10') then
--根據一站式業務資訊id,查詢對應的busiid
select busi_id into busiid from pd_busi_instance_inter where oss_busi_id=ossbusiid;
--更新電路代號
if(ele_key='8077') then
update pd_busi_instance_inter set busi_phy_number=ele_val where busi_id=busiid and loginaccept=log_accept;
end if;
--檢查元素值是否存在,有則更新,無則插入
if not query_m%isopen then
open query_m(log_accept, busiid, ele_key);
end if;
fetch query_m into element_val;
if not query_m%found then
insert into pd_element_instance_mid values(log_accept, '', busiid, ele_key, ele_val, '');
else
update pd_element_instance_mid set element_value=ele_val where loginaccept=log_accept and busi_id=busiid and element_id=ele_key;
end if;
close query_m;
--其它型別,更新正表
else
--根據一站式業務資訊id,查詢對應的busiid
select busi_id into busiid from pd_busi_instance_info where oss_busi_id=ossbusiid;
--更新電路代號
if(ele_key='8077') then
update pd_busi_instance_info set busi_phy_number=ele_val where busi_id=busiid and loginaccept=log_accept;
end if;
--檢查元素值是否存在,有則更新,無則插入
if not query_z%isopen then
open query_z(log_accept, busiid, ele_key);
end if;
fetch query_z into element_val;
if not query_z%found then
insert into pd_element_instance_info values(log_accept, '', busiid, ele_key, ele_val);
else
update pd_element_instance_info set element_value=ele_val where busi_id=busiid and element_id=ele_key and loginaccept=log_accept;
end if;
close query_z;
end if;
commit;
exception when others then
dbms_output.put_line('sqlcode : ' || sqlcode);
dbms_output.put_line('sqlerrm : ' || sqlerrm);
rollback;
end ossbusiinfoimport;
ibatis中呼叫:
Oracle儲存過程呼叫儲存過程
oracle儲存過程呼叫有返回結果集的儲存過程一般用光標的方式,宣告乙個游標,把結果集放到游標裡面,然後迴圈游標 declare newcs sys refcursor cs1 number cs2 number cstype table rowtype table列的個數和newcs返回的個數一樣...
ORACLE儲存過程
自定義函式開始 create or replace function fn wftemplateidget templatecategoryid number,organid number,templatemode number return number istemplateid number i...
Oracle 儲存過程
create or replace procedure p 有就替換,沒有就建立 iscursor c is select from emp for update begin for v emp in c loop if v emp.deptno 10 then update emp2 set sa...