2016-06-26 2 views
1

내가 같은 오류가 점점 오전에 :오류 : 00103 PLSQL 절차

Error(5,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior external language The symbol "begin" was substituted for "DECLARE" to continue.

Error(5,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior external language The symbol "begin" was substituted for "DECLARE" to continue.

내 코드는 다음과 같습니다

CREATE OR REPLACE PROCEDURE procExplicitCursorAccountSlct 
AS 
DECLARE 
    CURSOR C1 IS SELECT * FROM ACCOUNT; 
BEGIN 
    OPEN C1; 
    FOR i in C1 LOOP 
    FETCH C1 INTO ID,ACCOUNTTYPE,BALANCE; 
    EXIT WHEN C1%NOTFOUND; 
    DBMS_OUTPUT.PUT_LINE(ID||'-'||ACCOUNTTYPE||'-'||BALANCE); 
    DBMS_OUTPUT.PUT_LINE(C1%ROWCOUNT); 
    END LOOP; 
    CLOSE C1;  
END; 
+2

그냥'DECLARE' 키워드를 제거합니다. CREATE PROCEDURE의 구문을 참조하십시오. https://docs.oracle.com/database/121/LNPLS/create_procedure.htm#LNPLS01373 Threre는'IS/AS' 키워드 바로 뒤에 * declre_section *이지만이 절은 ** 포함하지 않습니다. DECLARE 키워드 **. 이 키워드는 익명 블록 및 트리거에서만 사용됩니다. – krokodilko

답변

1

이 시도하고 수정을위한 인라인 주석을 참조하십시오. 희망이 도움이됩니다.

CREATE OR REPLACE 
PROCEDURE procExplicitCursorAccountSlct 
AS 
    CURSOR C1 
    IS 
    SELECT 
     * 
    FROM 
     ACCOUNT; 
--Variabke declaration was missing 
    ID   NUMBER; 
    ACCOUNTTYPE VARCHAR2(100); 
    BALANCE  NUMBER; 
    --Variabke declaration was missing 
BEGIN 
    OPEN C1; 
    LOOP 
    FETCH 
     C1 
    INTO 
     ID, 
     ACCOUNTTYPE, 
     BALANCE; 
    EXIT 
    WHEN C1%NOTFOUND; 
    DBMS_OUTPUT.PUT_LINE(ID||'-'||ACCOUNTTYPE||'-'||BALANCE); 
    DBMS_OUTPUT.PUT_LINE(C1%ROWCOUNT); 
    END LOOP; 
    CLOSE C1; 
END; 
0

당신은 암시 적 루프 (그리고 DECLARE 너무 제거)와이 방법이 더 간단하게 만들 수 :

CREATE OR REPLACE PROCEDURE procExplicitCursorAccountSlct 
AS 
    CURSOR C1 IS SELECT * FROM ACCOUNT; 
BEGIN 
    FOR i in C1 LOOP 
    DBMS_OUTPUT.PUT_LINE(i.ID||'-'||i.ACCOUNTTYPE||'-'||i.BALANCE); 
    DBMS_OUTPUT.PUT_LINE(C1%ROWCOUNT); 
    END LOOP; 
END;