我使用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: