oracle 存储过程 游标

create or replace procedure t_ps_TryCalculate(v_date in varchar2)
AS
/*
每月绩效校验,根据参数判断员工业绩是否通过。
参数:v_date 绩效年月
*/
--定义错误变量
some_kinds_of_err EXCEPTION; -- Exception to indicate an error condition
v_ErrorCode NUMBER; -- Variable to hold the error message code
v_ErrorText VARCHAR2(2000); -- Variable to hold the error message text
v_Error_Sql varchar2(4000); --调试时使用的SQL语句
--定义使用到的变量
--定义游标
CURSOR C_RESULT_INPUT IS
select * from dual;    --游标中的SQL语句。
v_result_row C_RESULT_INPUT%ROWTYPE; --定义行类型
begin
--初始化值
v_count := 0;
v_temp_orgcode :='';
v_temp_becode := '';
OPEN C_RESULT_INPUT;
LOOP
FETCH C_RESULT_INPUT INTO v_result_row;
-- 假如没有检索到(主表)数据,结束循环处理
Exit when C_RESULT_INPUT%NOTFOUND;
--具体循环的内容
--DOING
END LOOP;
-- 关闭游标
CLOSE C_RESULT_INPUT;
Exception
--捕捉其他异常,并获得 捕获异常的内容
WHEN OTHERS THEN
v_ErrorCode := SQLCODE;
v_ErrorText := SUBSTR(SQLERRM, 1, 200);
--将错误信息写入日志表
insert into t_ps_running_log (run_id,run_date,run_content,run_type,run_kind)values(t_ps_running_log_seq.nextval,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),v_Error_Sql,'2','1');
commit;
end t_ps_TryCalculate;
posted on 2012-03-16 15:15  banditi  阅读(350)  评论(0编辑  收藏  举报