サブプロシージャで例外が発生した場合、戻り値はNULLだ!

ということがわかった。
サブファンクションの場合は例外処理部でRETURNを記述する必要がある。

create or replace package hoge
is
procedure parent;
end hoge;
/

create or replace package body hoge
is
procedure child(in_i IN NUMBER, in_rtn OUT NUMBER)
is
begin
	select station_cd into in_rtn from m_accounting where station_cd = 12132;
exception
	when others then
		dbms_output.put_line(SQLERRM);
end;

procedure parent 
is
v_rtn NUMBER := 1;
begin
	dbms_output.put_line('before parent v_rtn='||v_rtn);
	child(1, v_rtn);

	if v_rtn is null then
		dbms_output.put_line('NULL!');
	end if;
	
	dbms_output.put_line('after parent v_rtn='||v_rtn);
end;
end hoge;
/


結果

SQL> exec hoge.parent
before parent v_rtn=1
ORA-01403: データが見つかりません。
NULL!
after parent v_rtn=

PL/SQLプロシージャが正常に完了しました。