2012-06-18 115 views
1

錯誤:問題運行示例SQL

ORA-06550: line1, column 22: PLS-00103 Encountered the symbol "end-of-file" when expecting one of the following: * & = - + .......

PL/SQL塊:

DECLARE v_c number :=0; 
    BEGIN 
     SELECT COUNT(*) into v_c from all_sequences where sequence_name='TEST_SEQ' and sequence_owner='test'; 
     IF v_c = 1 THEN 
     execute immediate 'DROP SEQUENCE test.TEST_SEQ'; 
     END IF; 
    END; 
/
+0

爲什麼立即執行?爲什麼不只是做'那麼滴序列...'? – qJake

+4

@spikeX,你不能在PL/SQL塊中執行DDL。 – Ben

+0

此外,在問題中增加一點解釋或細節可能會有所幫助。不要只粘貼代碼。 – qJake

回答

4

我從您的文章中複製的代碼,並沒有問題,跑了它在這兩個的SQLDeveloper和的SQLPlus:

連接到: Oracle數據庫11g版本11.2.0.3.0 - 生產

prompt> DECLARE v_c number :=0;       
    2  BEGIN 
    3  SELECT COUNT(*) into v_c from all_sequences where sequence_name='TEST_SEQ' and sequence_owner='test'; 
    4  IF v_c = 1 THEN 
    5   execute immediate 'DROP SEQUENCE test.TEST_SEQ'; 
    6  END IF; 
    7  END; 
    8/

PL/SQL procedure successfully completed. 

您使用的是什麼工具?我最好的建議是在SQLPlus中嘗試一下,如果你仍然有錯誤,給我們展示會話的全文。

+0

也適用於TOAD 10.5 –

4

您只執行第一行而不是整個PL/SQL塊。

DECLARE v_c number :=0 
/

,導致:

DECLARE v_c number :=0 
       * 
ERROR at line 1: 
ORA-06550: line 1, column 22: 
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the 
following: 
* & = - + ; </> at in is mod remainder not rem 

正如其他建議,試試這個在sqlplus。