PLSQL
PLSQL
Contents
PL/SQL Constructs
Views
Triggers
Cursors
PL/SQL Constructs
PL/SQL is a combination of SQL along with the procedural features of programming
languages. It was developed by Oracle Corporation in the early 90's to enhance the
capabilities of SQL.
It is a block structured language that enables developers to combine the power of SQL with
procedural statements. All the statements of blocks are passed to oracle engine all at once
which increases processing speed and decreases the traffic.
Declare c_emp cursor for select Name, id, Address from employee [where
id=4];
Opening the Cursor
Opening the cursor allocates the memory for the cursor and makes it ready for
fetching the rows returned by the SQL statement into it. For example, we will
open the above defined cursor as follows :-
OPEN c_emp;
Fetching the Cursor
Fetching the cursor involves accessing one row at a time. For example, we will
fetch rows from the above-opened cursor as follows −
FETCH c_emp INTO c_id, c_name, c_addr;
Closing the Cursor
Closing the cursor means releasing the allocated memory. For example, we will
close the above-opened cursor as follows −
CLOSE c_emp;
Complete example of Explicit Cursor
Continue…
For any query contact me on WhatsApp.