Syntax for LOOP statement in Oracle PL/SQL

Example of LOOP Statement in Oracle PL/SQL

LOOP statement is executed at least once, we need to specify the EXIT clause to come out from LOOP statement.

Syntax:

LOOP
   <statements>
END LOOP;

Example of LOOP Statements:

SET SERVEROUTPUT ON
DECLARE 
   v_id number(2); 
BEGIN 
   v_id := 1;
   LOOP 
        dbms_output.put_line('id: ' || v_id); 
		v_id := V_id + 1;
		EXIT WHEN v_id > 10;
   END LOOP; 
END; 
/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.