LOOP … EXIT WHEN syntax LOOP –pl/sql statements EXIT WHEN condition; –pl/sql statements END LOOP; LOOP … EXIT WHEN example DECLARE i NUMBER:=4; BEGIN DBMS_OUTPUT.PUT_LINE(‘Start’); LOOP i := i + 1; EXIT WHEN i > 7; DBMS_OUTPUT.PUT_LINE(‘ i: ‘ || i); END LOOP; DBMS_OUTPUT.PUT_LINE(‘End’); END; Output Start i: 5 i: 6 i: 7 End
Author: Dev
PL/SQL Loop – Exit
In Oracle PL/SQL, the EXIT command is used to exit a loop prematurely. It can be used in both simple loops (like a basic FOR loop) and more complex loops (like a WHILE loop or a cursor FOR loop). When the EXIT command is encountered, the loop is immediately terminated and control is transferred to…(Continue Reading)
PL/SQL Add Column
To add a column to an existing table in Oracle PL/SQL, you can use the ALTER TABLE statement. The basic syntax is as follows: ALTER TABLE table_name ADD (column_name datatype [NULL | NOT NULL] [DEFAULT value]); Table Students STUDENT_ID FIRST_NAME LAST_NAME GENDER CITY 1 Daniel SCOTT M New York 2 Anthony SIMMONS M Chicago 3…(Continue Reading)
PL/SQL Create table
In Oracle PL/SQL, the CREATE TABLE statement is used to create a new table in a database. The basic syntax for creating a table is as follows: CREATE TABLE table_name ( column1 datatype constraint, column2 datatype constraint, column3 datatype constraint, …. ); table_name is the name of the table that you want to create. column1,…(Continue Reading)
PL/SQL Cursors
What is a PL/SQL cursor? A PL/SQL cursor is a pointer to a result set, or the data that results from a query. Cursors let you fetch one or more rows from the database into memory, process them, and then either commit or roll back those changes. How to use a PL/SQL cursor? In order…(Continue Reading)