0

I have written a small anonymous code block in PLSQL using For Loop. But it faield to execute with the error. I am using SQL Developer to execute it.

Code Block:

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

Error:

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:
2
  • 3
    Remove the single quotes around the select statement Commented Apr 4, 2016 at 11:46
  • Ahh! Thank You 'a_horse_with_no_name'. Commented Apr 4, 2016 at 11:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.