Write a program to display 1 to n numbers using loop in oracle?

1 answer

Answer

1020984

2026-07-31 12:10

+ Follow

You can use a PL/SQL block to display numbers from 1 to n in Oracle. Here's an example program:

<code class="language-sql">DECLARE

n NUMBER := 10; -- Change this value to your desired n BEGIN FOR i IN 1..n LOOP DBMS_OUTPUT.PUT_LINE(i); END LOOP; END; /

</code>

This code declares a variable n, then uses a FOR loop to iterate from 1 to n, printing each number using DBMS_OUTPUT.PUT_LINE. Make sure to enable output in your SQL environment to see the results.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.