Collections:
Use "FOR" Loop Statements in Oracle
How To Use "FOR" Loop Statements in Oracle?
✍: FYIcenter.com
If you have a block of codes to be executed repeatedly over a range of values, you can use the "FOR ... LOOP" statement. Here is a sample script on FOR statements:
DECLARE
total NUMBER := 0;
BEGIN
FOR i IN 1..10 LOOP
total := total + i;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Total: ' || TO_CHAR(total));
END;
Note that temporary variable "i" used in the FOR loop needs no declaration. This script should print this:
Total: 55
⇒ What Is NULL in PL/SQL in Oracle
⇐ Use "WHILE" Loop Statements in Oracle
2018-07-13, 2947🔥, 0💬
Popular Posts:
How To Revise and Re-Run the Last SQL Command in Oracle? If executed a long SQL statement, found a m...
How To End a Stored Procedure Properly in SQL Server Transact-SQL? Where the end of the "CREATE PROC...
What Happens to the Current Transaction If a START TRANSACTION Is Executed in MySQL? If you are in a...
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
How To Round a Numeric Value To a Specific Precision in SQL Server Transact-SQL? Sometimes you need ...