What is the difference between explicit and implicit cursors in Oracle?

Answer

An implicit cursor is one created "automatically" for you by Oracle when you execute a query. It is simpler to code, but suffers from

    inefficiency (the ANSI standard specifies that it must fetch twice to check if there is more than one record)
    vulnerability to data errors (if you ever get two rows, it raises a TOO_MANY_ROWS exception)

Example

SELECT col INTO var FROM table WHERE something;

An explicit cursor is one you create yourself. It takes more code, but gives more control - for example, you can just open-fetch-close if you only want the first record and don't care if there are others.

Example

DECLARE   
  CURSOR cur IS SELECT col FROM table WHERE something;
BEGIN
  OPEN cur;
  FETCH cur INTO var;
  CLOSE cur;
END;

All plsql Questions

Ask your interview questions on plsql

Write Your comment or Questions if you want the answers on plsql from plsql Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---