explicitcursorinoracleplsql

                             Concept of explicit cursor in oracle pl/sql

What is Cursor?

     If we want to retrieve multiple rows from the table then we will go for Cursor.
    
     Cursor will works like line by line execution.
    
     i.e. After successful processing of first record then cursor will retrieve and process the following
           records one by one.

How to use Cursor?

Follow the below steps to use Cursor:

Declare cursor - - - > It is used to define a cursor that will be subsequently used to open and fetch 
                                   records.
Open cursor     - - - > Used to open the cursor
Fetch cursor     - - - > It is used to retrieve the record from cursor.
Close cursor    - - - > Once the process is completed, the cursor will be closed.

DECLARE CURSOR EMP1 IS          

SELECT Empname, Salary from EMPLOYEE;
                  vename EMPLOYEE.Empname%type;
                  vsal EMPLOYEE.Salary%type;
BEGIN
          OPEN EMP1;LOOP
          FETCH EMP1 into vename, vsal;
          exit when EMP1%notfound;
          dbms_output.put_line (vename[]' '[lvsal);
ENDLOOP;
         CLOSE EMP1;

END;

                                         Share your thoughts to improve our blog !!!

               

Comments

Popular posts from this blog

Decode function in Oracle pl/sql

SUBSTR function in Oracle pl/sql 

StoredprocedureinOracleplsql