2014-04-25 4 views
0

이 내 저장 프로 시저컴파일시 에러 및 실행 오류

create or replace procedure EMP_DB.std_stdsp 
(stid in out varchar(10), 
name in out varchar(100) 
) 
is 
begin 
select *from students s 
where S.STDID in(stid) 
and S.STDNME in (name); 
end EMP_DB.std_stdsp; 
/

컴파일 오류

경고입니다 : 컴파일하지만 컴파일 오류가

것은 내가 저장 실행 절차, 난 오류가 발생했습니다

EXEC EMP_DB.std_stdsp('1','Farhat'); 

오류

BEGIN EMP_DB.std_stdsp('1','Farhat'); END; 
Error at line 1 
ORA-06550: line 1, column 14: 
PLS-00905: object EMP_DB.STD_STDSP is invalid 
ORA-06550: line 1, column 7: 
PL/SQL: Statement ignored 

다시 선택에서 여러 레코드를 얻기 위해 의도처럼 보이는 사전

+0

'create' 문 바로 다음에'show errors'를 할 수 있습니다; 'user_errors' 뷰를 나중에 질의 할 수도 있습니다. 어느 것이 든 실제 컴파일 오류를 보여줄 것이고, 현재 유효하지 않은 모든 객체에 대한 후자가 있으므로 객체 유형과 이름을 필터링 할 수 있습니다. –

답변

1

의 모든 하나의 도움이 와요 고마워요. 여러 레코드를 처리하려면 루프가 필요합니다. 다음은 컴파일해야합니다 (미안, 테스트하지 않음)

create or replace procedure EMP_DB.std_stdsp ( 
    stid in out varchar(10), 
    name in out varchar(100)) is 
begin 
    for rec in (select * 
       from students s 
       where S.STDID in(stid) 
        and S.STDNME in (name)) loop 
    dbms_output.put_line ('student record'); 
    -- replace the dbms_output and this comment with some meaningful code 
    -- any code inside the loop will execute once for each student record 
    -- returned from the select statement 
    end loop; 
end EMP_DB.std_stdsp; 
/

두 번째 오류는 프로 시저가 컴파일되지 않았기 때문입니다.

'1,3,5'과 같은 것을 stid 매개 변수에 전달하여 레코드 1, 3 및 5를 가져 오려는 경우 의도 한대로 작동하지 않습니다. 인은 전체 '1,3,5'을 단일 값으로 취합니다. 표의 레코드를 일치 시키려면 stdid 열이 정확히 '1,2,3'이어야합니다. 여러 레코드를 가져 오려면 in 대신 like을 사용하도록 전환 할 수 있습니다. 그래도 와일드 카드를 추가해야합니다.