How to write a for loop in Oracle sqlplus?

I'm trying to write a for loop in Oracle sqlplus interface. When writing the loop statement an pressing enter, I get an error:

SQL> for i in 1..10 loop
SP2-0734: unknown command beginning "for i in 1..." - rest of line ignored.

Is there something wrong with my for loop clause?


For loop is a PL/SQL construct. Try wrapping your PL/SQL in BEGIN/END block.

If you need to declare variables, start with a DECLARE. Something like this:

set serveroutput on
  for a in 1..10 loop
  end loop;

Hope that helps.

PS Note that set serveroutput on is a SQL*Plus command, and not part of PL/SQL. It just turns on output so you'll see the output from the dbms_output.put_line() function.

Need Your Help

Working on DOM elements, finding next class

javascript jquery

I have problem with working on DOM elements.

Silverlight: Image Source with no file extension doesn`t display

image silverlight-4.0

In my Silverlight project, images for which the source URI does not contain the file extension don`t display, although the documentation says it should.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.