create or replace procedure proc_data_check is
--定义变量
V_LOCK_ID INTEGER;
v_lockhandle VARCHAR(128);
V_RELEASE_ID INTEGER;
--定义出错异常信息编码
v_error_code VARCHAR2(10) := ‘‘;
--定义错误异常描述信息
v_error_message VARCHAR2(1000) := ‘‘;
cursor check_orgs is
select org_code, org_name from check_org;
begin
DBMS_LOCK.ALLOCATE_UNIQUE(‘PROC_DATA_CHECK‘, v_lockhandle, 86400);
V_LOCK_ID := DBMS_LOCK.REQUEST(v_lockhandle, DBMS_LOCK.X_MODE, 0, FALSE);
if (V_LOCK_ID = 0) then
for check_org in check_orgs loop
null;
end loop;
V_RELEASE_ID := dbms_lock.release(v_lockhandle);
COMMIT;
end if;
commit;
EXCEPTION
WHEN OTHERS THEN
V_RELEASE_ID := dbms_lock.release(v_lockhandle);
--得到异常编码
V_ERROR_CODE := SQLCODE;
--得到异常描述信息
V_ERROR_MESSAGE := SQLERRM;
--将异常信息维护到异常表中
end proc_data_check;
本文出自 “高辉博客” 博客,转载请与作者联系!
原文地址:http://qjcghwsj.blog.51cto.com/3860557/1568185