我有以下步骤:
procedure insert_header(p_push_date in date,
p_source_serial in varchar2,
p_source_start_date in date,
p_source_end_date in date
) is
id_temp number;
begin
-- check for errors
if p_push_date is null
then
result_code := 9213;
--raise_application_error(-RESULT_CODE, 'push_date cannot be null');
elsif p_source_serial is null
then
result_code := 9333;
--raise_application_error(-RESULT_CODE, 'source_serial cannot be null');
end if;
-- if there are no errors, do insert
if result_code is null
then
-- fetch sequence number
id_temp := header_seq.nextval;
result_code:=0;
open o_cur_results for
select id_temp as id
from dual;
/*insert into*/
end if;
提交; 结束;
当插入一些无效参数时,该过程不应显示任何弹出错误窗口。相反,它应该只返回result_code变量。
有人可以演示如何做到吗?
答案 0 :(得分:0)
/* Formatted on 4/23/2019 8:17:42 AM (QP5 v5.256.13226.35538) */
PROCEDURE insert_header (p_push_date IN DATE,
p_source_serial IN VARCHAR2,
p_source_start_date IN DATE,
p_source_end_date IN DATE,
result_code OUT NUMBER)
IS
id_temp NUMBER;
BEGIN
-- check for errors
IF p_push_date IS NULL
THEN
result_code := 9213;
RETURN;
--raise_application_error(-RESULT_CODE, 'push_date cannot be null');
ELSIF p_source_serial IS NULL
THEN
result_code := 9333;
RETURN;
--raise_application_error(-RESULT_CODE, 'source_serial cannot be null');
END IF;
-- if there are no errors, do insert
IF result_code IS NULL
THEN
-- fetch sequence number
id_temp := header_seq.NEXTVAL;
result_code := 0;
OPEN o_cur_results FOR SELECT id_temp AS id FROM DUAL;
/*insert into*/
END IF;
COMMIT;
END;