Re: Quick (hopefully) pl/sql cursor question

From: Lothar Flatz <l.flatz_at_bluewin.ch>
Date: Fri, 27 Sep 2019 20:53:59 +0200
Message-ID: <5a6dec60-b665-9d90-c23e-bc42675f0df9_at_bluewin.ch>


Hi Joe,

please understand that initialization and loaded with data are different things: A cursor is initialized when it is opened. So that means that the cursor variable exists and memory is reserved to run the cursor. You still do not have data. If it is a DML cursor it is executed on open and there will never be any data other than the return value, error status etc.
For a select statement the first data is present after the first fetch. If it is a for loop the cursor is open implicitly and the first fetch is issued implicitly as well. Thus, the first data will be present inside the loop on the first execution.
The sequence of the definition of the procedures does not matter at all with respect to your question.

Regards

Lothar

Am 27.09.2019 um 19:26 schrieb Sweetser, Joe:
> Greetings,
>
> Does anyone know exactly when an explicit cursor is initialized in pl/sql? I understand I may need to supply more info, but I am no pl/sql wizard and don't know exactly what info is needed.
>
> I have a package with multiple procedures. One those procedures contains additional procedures. And one of those additional procedures has some cursors. Sorta like this:
>
> Package
> - procedure1
> - procedure2
> - procedure3
> - procedure3a
> - cursor 1
> - cursor 2
>
> Would the cursors be initialized when procedure3 is called or when procedure3a is called? I would guess procedure3a but the developer is seeing some weirdness where it looks like it's when procedure3 is called.
>
> There is no explicit "open cursor" call. It is used in a for loop, so I think oracle opens it automagically. But, again, I am trying to determine the initialization. When is the cursor loaded with data?
>
> Any/all ideas/suggestions welcome.
>
> Thanks,
> -joe
>
> This e-mail transmission and any attachments that accompany it may contain information that is privileged, confidential or otherwise exempt from disclosure under applicable law and is intended solely for the use of the individual's to whom it was intended to be addressed. If you have received this e-mail by mistake, or you are not the intended recipient, any disclosure, dissemination, distribution, copying or other use or retention of this communication or its substance is prohibited. If you have received this communication in error, please immediately reply to the author via e-mail that you received this message by mistake and also permanently delete the original and all copies of this e-mail and any attachments from your computer. Please note that coverage cannot be bound or altered by sending an email. You must receive written confirmation from a representative of our firm to put coverage in force or make changes to an existing policy.
> --
> http://www.freelists.org/webpage/oracle-l
>
>

-- 




--
http://www.freelists.org/webpage/oracle-l
Received on Fri Sep 27 2019 - 20:53:59 CEST

Original text of this message