첫 번째 쿼리가 null 값을 반환하거나 아무런 레코드도 반환하지 않으면 프로 시저에서 두 번째 쿼리는 두 번째 쿼리도 실행하면 null 값이 반환되거나 레코드가 반환되지 않으므로 기본값을 반환해야합니다. 이 절차를 만드는 방법? else 문이나 예외 처리기를 사용해야합니까?첫 번째 쿼리가 null 값을 반환하면 내 두 번째 쿼리도 실행해야합니다. 두 번째 쿼리는 null로 표시되고 내 기본값은 표시된대로
create or replace function get_queue_id
(p_product_code in mo_product_master.product_code%type
, p_intermediary_code in intrfc_intermediary_mstr_view.intermediary_code%type)
return mo_product_master.queue_id%type
as
return_value number;
begin
-- preferred_choice
begin
select pm.queue_id
into return_value
from mo_product_master pm
where pm.product_code=p_product_code
exception
when no_data_found then
null;
end;
if return_value is null then
-- second_choice
begin
select qim.queue_id
into return_value
from mo_queue_inter_map_master qim
, intrfc_intermediary_mstr_view imv
where qim.category_code =imv.category_code
and imv.intermediary_code=p_intermediary_code;
exception
when no_data_found then
null;
end;
if return_value is null then
-- default_value
select id
into return_value
from mo_queue_master
where queue_name='others'
and status='Active';
end if;
end if;
return return_value;
end;
/
그것은 조금 투박하지만이 작업을 수행합니다
고마워요. 당신의 코드가 나를 도왔습니다. – leelavinodh