Difference between FETCH/FOR to loop a CURSOR in PL/SQL

后端 未结 4 1632
有刺的猬
有刺的猬 2020-12-25 08:35

I know that fetching a cursor will give me access to variables like %ROWCOUNT, %ROWTYPE, %FOUND, %NOTFOUND, %ISOPEN

...but I was wondering if there are any other rea

4条回答
  •  时光说笑
    2020-12-25 09:31

    I don't know about any crucial differences in this two realizations besides one: for ... loop implicitly closes the cursor after the loop is finished and if open ... fetch ... close syntax you'd rather close the cursor yourself (just a good manner) - thought this is not a necessity: Oracle will close the cursor automatically outbound the visibility scope. Also you can't use %FOUND and %NOTFOUND in for ... loop cursors.

    As for me I find the for ... loop realization much easier to read and support.

提交回复
热议问题