2017-10-11 11 views
-3

이이 문제 문이 나에게 주어집니다 :다음 쿼리에서 'case'문을 사용할 위치는 어디입니까?

1

create or replace function disp_player_name (play_id in number) 
return varchar is status_name varchar(100); 
begin 
select country into status_name from player where id=play_id; 
return status_name; exception 
when no_data_found then status_name := 'No such country' 
return status_name; 
end;/ 

어디 나는 '경우'문제 문에 주어진 상태를 인쇄를 사용해야합니까?

답변

0

이것은 숙제와 같지만 SELECT INTO를 마친 직후입니다.

create or replace function disp_player_name (play_id in number) 
return varchar is status_name varchar(100); 
begin 

select country into status_name from player where id=play_id; 

CASE 
      WHEN status_name = 'India' THEN 
       status_name := 'Player belongs to India'; 

END CASE; 

return status_name; 

exception 
when CASE_NOT_FOUND then status_name := 'No such country' 

return status_name; 
end;/