运行Sample SQL时出现问题

时间:2012-06-18 17:25:13

标签: sql oracle plsql

错误:

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

PL / SQL Block:

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

2 个答案:

答案 0 :(得分:4)

我从帖子中复制了代码并在SQLDeveloper和SQLPlus中运行它没有问题:

连接到: Oracle Database 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中尝试,如果仍有错误,请向我们展示会话的全文。

答案 1 :(得分: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中尝试。