by 티라미수꿀맛 [2019.07.16 11:41:15]
set serverout on
create or replace procedure emp_proc
(
e_no in employees.employee_id%type,
e_name out employees.first_name%type,
e_sal out employees.salary%type
)
is
begin
select first_name, salary into e_name ,e_sal
from employees
where employee_id =e_no;
dbms_output.put_line(e_name);
if sql%notfound then
dbms_output.put_line('The staff does not exits.');
end if;
end;
/
사번입력을 받아서 EXECUTE EMP_PROC(100) 이런식으로 해서 SELECT 문 조회를 하는데
없는 사번이 나오면 THE STAFF DOES NOT EXITS 문장을 나오게하는 프로시저를 짜고싶습니다.
아무리 생각해도 뭐가 문제인지 잘 모르겠어서 도움을 요청합니다.
PRA-06550: 줄 1, 열74:PLS-00306: wrong number or types of arguments in call to 'EMP_PROC'
ORA-06550: 줄 1, 열74:PL/SQL: Statement ignored
계속 이오류가나오는데 무슨 타입이 틀린건지를 잘모르겠습니다.
EXECUTE EMP_PROC('100') 이거 아닐까요.. 문자..
create or replace procedure emp_proc
(
e_no in emp.empno%type
)
is
v_ename emp.ename%type;
begin
select ename into v_ename
from emp
where empno = e_no;
dbms_output.put_line(v_ename);
exception
when no_data_found then
dbms_output.put_line('The staff does not exits.');
end;
감사합니다.
그렇다면 %notfound는 언제 사용할수있는건가요???
http://www.gurubee.net/lecture/1062 여기 들어가보면 select into 문에 %found 를사용하던데 이거는 무슨경우인가요??
소주쵝오님 sql%notfound는 사용하면안되는건가요??
보니까 no_data_found를 다 쓰던데 notfound는 왜안쓰는건지 궁금합니다.
select into문을 사용시에는 해당 조건의 row가 없는 경우 no_data_found가 발생하는데요
no_data_found 가 발생하면 정상 실행이 중단되고 제어가 블록의 예외 처리 부분으로 넘어갑니다.
그래서 %notfound 속성의 의미가 없어요~
1. 호출시 오류는
- 변수는 3개인데 1개만 입력해서 오류
- 아웃변수 2개 선언해서 같이 입력해 줘야 함
2. notfound 는
- select ~ into 는 0 row 시 에러가 나버리기 때문에 소용 없습니다.
- 에러는 익셉션으로 잡아줘야 합니다.