2
create or replace procedure p_inout
(v_emp_lname in varchar2)
as
v_first_name varchar2(20);
begin
select first_name into v_first_name
from employees
where last_name=v_emp_lname;
dbms_output.put_line(v_first_name);
end p_inout;
/
위의 코드는 성을 입력 할 때 이름을 반환하는 데 사용됩니다. 그러나 중복 된 성이 많이 있습니다. 그리고 쿼리를 실행하려고하면이 오류가 발생합니다.두 개 이상의 레코드를 반환하는 방법?
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "HR.P_INOUT", line 6
ORA-06512: at line 1
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requested
레코드보다 많은 데이터를 반환하려면 어떻게합니까?
v_first_name 변수를 사용할 특별한 이유가 있습니까? – Dee
커서를 참조하십시오. http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/cursor_for_loop_statement.htm#LNPLS1155 – otisonoza