ORA-06550: line 7, column 3: PLS-00103: Encountered the symbol "end-of-file"

Viewed 365

I am trying to execute the following query in Sql Test:

DECLARE 
   a number(2); 
BEGIN 
   FOR a in 10 .. 20 LOOP 
      dbms_output.put_line('value of a: ' || a); 
  END LOOP;
END;

Error:

ORA-06550: line 7, column 3: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ; The symbol ";" was substituted for "end-of-file" to continue.

I've tryed put the symbol "/" but nothing change.

1 Answers

Code you wrote is OK:

SQL> DECLARE
  2     a number(2);
  3  BEGIN
  4     FOR a in 10 .. 20 LOOP
  5        dbms_output.put_line('value of a: ' || a);
  6    END LOOP;
  7  END;
  8  /
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
value of a: 20

PL/SQL procedure successfully completed.

SQL>

Looks like SQL Test site has problems in interpreting it. A field you put the query into is titled as "SQL Query"; technically, your code is an anonymous PL/SQL script, not a simple "query".

Help on the site is rather poor and doesn't help at all. I tried to

  • put your code into the left field ("SQL Script"), didn't help
  • create a stored procedure based on your code - no improvement either

Then I gave up.

Maybe someone knows how to make it work; meanwhile, I'd suggest some other site. Have a look at 17 sites for SQL practice, I hope you'll find something useful.

Related