2014-01-13 65 views
-2

執行下面的過程中出現錯誤。在oracle中執行過程期間發生錯誤

CREATE OR REPLACE PROCEDURE P_SUMIT (P_FEED IN FEED.FEED_ID%TYPE, P_OPCO_ID IN FEED.OPCO_ID%TYPE) 
AS 
BEGIN 
DECLARE V_PCF_PATTERN FEED.PCF_PATTERN%TYPE; 
DECLARE CURSOR C_FEED FOR SELECT PCF_PATTERN FROM FEED WHERE FEED_ID=P_FEED AND OPCO_ID=P_OPCO_ID; 
    OPEN C_FEED; 
    LOOP 
    FETCH C_FFED INTO V_PCF_PATTERN; 
    EXIT WHEN C_FEED%NOTFOUND; 
    DBMS_OUTPUT.PUT_LINE(V_PCF_PATTERN); 
    END LOOP; 
    CLOSE C_FEED; 
END; 

錯誤日誌:

3/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. 

4/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 

請協助。

回答

0

DECLARE陳述應該在AS之後關鍵字。

CREATE OR REPLACE PROCEDURE P_SUMIT (P_FEED IN FEED.FEED_ID%TYPE, P_OPCO_ID IN FEED.OPCO_ID%TYPE) 
    AS 
     V_PCF_PATTERN FEED.PCF_PATTERN%TYPE; 
     CURSOR C_FEED IS SELECT PCF_PATTERN FROM FEED WHERE FEED_ID=P_FEED AND OPCO_ID=P_OPCO_ID; 
    BEGIN 
     OPEN C_FEED; 
     LOOP 
     FETCH C_FEED INTO V_PCF_PATTERN; 
     EXIT WHEN C_FEED%NOTFOUND; 
     DBMS_OUTPUT.PUT_LINE(V_PCF_PATTERN); 
     END LOOP; 
     CLOSE C_FEED; 
    END P_SUMIT; 
/
+0

CURSOR FOR SELECT? – SriniV

+0

謝謝,我沒有注意到它,只是從OP的格式。 –

+0

我也回答了同樣的問題,並且有人回答了一個問題。所以我刪除它。仍然奇怪爲什麼downvotes,也沒有理由。 – SriniV

0

這裏不需要顯式光標,或者參數前綴爲「p_」。隱式遊標寫得更快,更健壯,性能更好。

create or replace procedure p_sumit (
    feed_id in feed.feed_id%type, 
    opco_id in feed.opco_id%type) 
as 
begin 
    for c_feed in (
    select pcf_pattern 
    from feed 
    where feed_id = p_sumit.feed_id and 
      opco_id = p_sumit.opco_id) 
    loop 
    dbms_output.put_line(c_feed.pcf_pattern); 
    end loop; 
end; 
相關問題