How to use Implicit and Explicit Cursors?
Oracle provides two types of cursors.
1. Implicit
2. Explicit
If we try to understand what are these two, then we have
Implicit cursors are those created automatically by oracle whenever we select data from table into variables.
Example :
DECLARE l_ename emp.ename%TYPE;BEGIN SELECT ename INTO l_ename FROM emp WHERE empno = 7788;
DBMS_OUTPUT.put_line ('Employee name s : ' || l_ename);END;
Explicit cursors are those cursors created by us and declared before begin.
DECLARE
l_ename emp.ename%TYPE;
CURSOR c1
IS
SELECT ename
FROM emp
WHERE empno = 7788;
BEGIN
OPEN c1;
FETCH c1 INTO l_ename;
CLOSE c1;
DBMS_OUTPUT.put_line ('Employee name s : ' || l_ename);
END;
Difference:
Explicit cursors can be controlled by by cursor attributes but implicit does not have these controls
Attributes are:
%FOUND Attribute:
%ISOPEN Attribute:
%NOTFOUND Attribute :
%ROWCOUNT Attribute :
No comments:
Post a Comment
Please do not add any spam links or abusive comments.