Implicit cursor


Cursor:-
A cursor is a pointer to a private SQL area that stores information about processing a specific SELECT or DML statement.

types of cursors
1. Implicit cursor
2. Explicit cursor

1. Implicit cursor :- A cursor that is constructed and managed by PL/SQL is an implicit cursor.  
these cursors are automatically created by oracle every time when you run any DML statements and very imporatant thing we can not control the behviour of these cursors.

2. Explicit Cursor:-
first of all my dear friends Explicit cursors are user defined cursors it means these cursors are created by user only and its bheaviour is controled by user only .


--====================================================
--Example:- --Implicit cursor
DML events are:-

1. Insert
2. Update
3. Delete

--====================================================

select * from XX_EMP_TL

EMPNO
ENAME
HIREDATE
DOB
GENDER
SAL
DEPTNO
CREATION_DATE
JOB
COMM
1000
Sachin
11-Sep-85
01-Mar-20
M
25000
20
21-04-2020 18:46
MANAGER

1002
Kumar
01-Aug-82
11-Mar-20
M
125000
20
21-04-2020 18:46


1008
Sonu
11-Sep-85
01-Mar-20
M
2500
10
21-04-2020 18:46
CLERK

1003
Chavi
25-Mar-81
15-Feb-20
F
5000
20
21-04-2020 18:46
CLERK

1006
Ravi
11-Sep-89
01-Mar-19
M
2500
10
21-04-2020 18:46
CLERK

1005
Vinod
18-Sep-86
01-Mar-20
M
17000
30
21-04-2020 18:46
DEVELOPER

1004
Neel
28-Jan-88
19-Jul-19
M
27000
30
21-04-2020 18:46
MANAGER

1007
Manoj
11-Sep-85
09-Mar-18
M
18000
10
21-04-2020 18:46
DEVELOPER

1001
Amit
11-Sep-80
01-Jan-20
M
10000
40
21-04-2020 18:46
DEVELOPER




-- INSERT --

Insert into XX_EMP_TL values ( 1009,    'Nitin Kumar',    '11-Sep-1985',    '11-Mar-2020',    'M' ,   '21000',    '20',    sysdate,    'DEVELOPER', ''    )




DECLARE

BEGIN

Insert into XX_EMP_TL values ( 1009,    'Nitin Kumar',    '11-Sep-1985',    '11-Mar-2020',    'M' ,   '21000',    '20',    sysdate,    'DEVELOPER', ''    );

END;








-- INSERT --

DECLARE

BEGIN

Insert into XX_EMP_TL values ( 1009,    'Nitin Kumar',    '11-Sep-1985',    '11-Mar-2020',    'M' ,   '21000',    '20',    sysdate,    'DEVELOPER', ''    );


    IF (SQL%FOUND) THEN
    dbms_output.put_line ('Done');
    ELSE
    dbms_output.put_line ('Not Done');
    END IF;

END;

OUTPUT:- Done

select * from XX_EMP_TL


-- UPDATE --

update XX_EMP_TL
set COMM = 100
where DEPTNO=10;


DECLARE

BEGIN

update XX_EMP_TL set COMM = 100 where DEPTNO=10;


    IF (SQL%FOUND) THEN
    dbms_output.put_line ('Done');
    ELSE
    dbms_output.put_line ('Not Done');
    END IF;

END;



-- DELETE --

delete from XX_EMP_TL where empno = 1009



Comments

Popular posts from this blog

E-Text Report In Fusion | Types of E-Text reports

Supplier API's

How to pass default Parameter in cursor