I am a bit rusty on my cursor lingo in PL/SQL. Anyone know this?
相关问题
- Can I skip certificate verification oracle utl_htt
- Can I skip certificate verification oracle utl_htt
- how to calculate sum time with data type char in o
- keeping one connection to DB or opening closing pe
- System.Data.OracleClient not working with 64 bit O
相关文章
- node连接远程oracle报错
- oracle 11g expdp导出作业调用失败,提示丢包。
- 执行一复杂的SQL语句效率高,还是执行多少简单的语句效率高
- Oracle equivalent of PostgreSQL INSERT…RETURNING *
- Difference between FOR UPDATE OF and FOR UPDATE
- Oracle USING clause best practice
- Is there a method in PL/SQL to convert/encode text
- PHP PDO installation on windows (xampp)
Implicit cursor returns only one record and are called automatically. However, explicit cursors are called manually and can return more than one record.
I know this is an old question, however, I think it would be good to add a practical example to show the difference between the two from a performance point of view.
From a performance point of view, Implicit cursors are faster.
Let's see the performance difference between the two:
So, a significant difference is clearly visible.
More examples here.
Explicit...
cursor foo is select * from blah; begin open fetch exit when close cursor yada yada yada
don't use them, use implicit
cursor foo is select * from blah;
for n in foo loop x = n.some_column end loop
I think you can even do this
for n in (select * from blah) loop...
Stick to implicit, they close themselves, they are more readable, they make life easy.
In answer to the first question. Straight from the Oracle documentation
As stated in other answers, implicit cursors are easier to use and less error-prone.
And Implicit vs. Explicit Cursors in Oracle PL/SQL shows that implicit cursors are up to two times faster than explicit ones too.
It's strange that no one had yet mentioned Implicit FOR LOOP Cursor:
Another example on SO: PL/SQL FOR LOOP IMPLICIT CURSOR.
It's way more shorter than explicit form.
This also provides a nice workaround for updating multiple tables from CTE.
An explicit cursor is one you declare, like:
An implicit cursor is one created to support any in-line SQL you write (either static or dynamic).