执行匿名块时出现Oracle PLSQL错误 - 遇到符号“LOOP”

时间:2016-04-04 11:43:46

标签: oracle plsql

我使用For循环在PLSQL中编写了一个小的匿名代码块。但它可以用错误执行。我正在使用SQL Developer来执行它。

代码块:

SET serveroutput ON;
DECLARE
BEGIN
  FOR rec IN ('SELECT 1 from dual')
  LOOP
    DBMS_OUTPUT.PUT_LINE(sysdate);
  END LOOP;
END;
/

错误:

Error starting at line 2 in command:
DECLARE
BEGIN
  FOR rec IN ('SELECT 1 from dual')
  LOOP
    DBMS_OUTPUT.PUT_LINE(sysdate);
  END LOOP;
END;
Error report:
ORA-06550: line 4, column 3:
PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:

   * & - + / at mod remainder rem .. <an exponent (**)> ||
   multiset year day
ORA-06550: line 6, column 3:
PLS-00103: Encountered the symbol "END" when expecting one of the following:

   begin function pragma procedure subtype type <an identifier>
   <a double-quoted delimited-identifier> current cursor delete
   exists prior
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

0 个答案:

没有答案