Home » Other » Training & Certification » Explicit cursor v Implicit cursor
Explicit cursor v Implicit cursor [message #359306] Fri, 14 November 2008 11:22 Go to next message
registereduser
Messages: 52
Registered: June 2008
Location: Toronto
Member
Under which situation it is necessary to use an explicit cursor?
Re: Explicit cursor v Implicit cursor [message #359308 is a reply to message #359306] Fri, 14 November 2008 11:48 Go to previous messageGo to next message
registereduser
Messages: 52
Registered: June 2008
Location: Toronto
Member
I am bit confused. I got the standard answers as follows:

"You use explicit cursors when you are sure that the SQL statement will return more than one row. "

I believe the answer is incorrect since I can also use implicit cursor to handle this. When I say "implicit cursor", I mean FOR ... IN (SELECT ... ) LOOP.

Now the focus is on the definition of what explicit cursor is and what implicit cursor is. Look at Oracle materials FOR LOOP cursor is classified as shortcut to explicit cursor, but in practical world, it classified as implicit cursor. I think what is why.

Please correct me if I am wrong.

Re: Explicit cursor v Implicit cursor [message #359309 is a reply to message #359308] Fri, 14 November 2008 11:50 Go to previous messageGo to next message
registereduser
Messages: 52
Registered: June 2008
Location: Toronto
Member
We indeed have three kind of cursors.
Re: Explicit cursor v Implicit cursor [message #359311 is a reply to message #359309] Fri, 14 November 2008 12:05 Go to previous messageGo to next message
registereduser
Messages: 52
Registered: June 2008
Location: Toronto
Member
For this third kind of cursor, let us call it Explicit Shortcut Cursor, there are two forms:

1. Cursor declared in declaration block

DECLARATION
CURSOR c_1 IS
SELECT col_1
FROM tab_1;

BEGIN
FOR i IN c_1 LOOP
END LOOP;

2. Not declared

BEGIN
FOR i IN (SELECT col_1 FROM tab_1) LOOP
END LOOP;

Re: Explicit cursor v Implicit cursor [message #359313 is a reply to message #359311] Fri, 14 November 2008 12:41 Go to previous message
registereduser
Messages: 52
Registered: June 2008
Location: Toronto
Member
I think I was wrong. If a cursor has been declared, it is clearly an explicit cursor. The third kind cursor can be called Undeclared Explicit Cursor, on contrast to the Implicit Cursor as called by almost all real world programmers, including Ask Tom Oracle, dba-oracle.com.
Previous Topic: OCA Paper 2 - 1Z0-147 Program with PL/SQL
Next Topic: OCA Certification
Goto Forum:
  


Current Time: Sat Aug 30 06:03:18 CDT 2014

Total time taken to generate the page: 0.10772 seconds