Re: Quick (hopefully) pl/sql cursor question

  • From: Andy Sayer <andysayer@xxxxxxxxx>
  • To: "Sweetser, Joe" <JSweetser@xxxxxxxx>
  • Date: Fri, 27 Sep 2019 21:20:18 +0100

That doesn’t really indicate any sort of problem, just a fear of something
with no evidence that it’s happening.

Perhaps they have more evidence, but I’m tempted to say “works on my
machine”.

Whether something reinitializes doesn’t matter unless you see a problem
occurring due to it. PL/SQL is a great programming language, people use it
with huge success. It’s unlikely that this vague problem is anything to do
with the language if it does exist.

Hope that helps,
Andy

On Fri, 27 Sep 2019 at 20:15, Sweetser, Joe <JSweetser@xxxxxxxx> wrote:

I am not sure of the exact problem, but the message I got from the
developer was something like this:



--- if the cursors are initialized when ‘procedure3a’ is called, that's
good.  If they are initialized when ‘procedure3’ is called, that's bad.



Taking that with Lothar’s previous explanation(s), I will go back to
developer and make sure they understand that c2 is reinitialized every time
the c1 loop iterates and that it doesn’t really have anything to do with
the procedure order, per se.



Thanks again to all,

-joe



*From:* oracle-l-bounce@xxxxxxxxxxxxx <oracle-l-bounce@xxxxxxxxxxxxx> *On
Behalf Of *Andy Sayer
*Sent:* Friday, September 27, 2019 1:03 PM
*To:* l.flatz@xxxxxxxxxx
*Cc:* oracle-l@xxxxxxxxxxxxx
*Subject:* Re: Quick (hopefully) pl/sql cursor question



What weirdness is being seen exactly?



On Fri, 27 Sep 2019 at 19:58, Lothar Flatz <l.flatz@xxxxxxxxxx> wrote:

Would c2 still be initialized at the start of the ‘For y’ loop??  I think
so but want to confirm.

C2 will reinitialize for every  iteration of the c1 loop. "Still" does not
apply here.




Am 27.09.2019 um 20:52 schrieb Sweetser, Joe:

Thanks!



To be clear, procedure3a has 2 cursor ‘definitions’ in the declaration
section.  My tabs didn’t work for spacing last time.  I apologize if that
happens again.



Procedure 3a is



Cursor c1 is select ….

Cursor c2 is select….



Begin

   For x in c1 loop

      Declare

           -set some constants

      Begin

           For y in c2 loop

           Do some stuff

       End loop;
   End loop;

End;



Would c2 still be initialized at the start of the ‘For y’ loop??  I think
so but want to confirm.



Thanks again,

-joe



*From:* Jacek Gębal <jgebal@xxxxxxxxx> <jgebal@xxxxxxxxx>
*Sent:* Friday, September 27, 2019 12:32 PM
*To:* Sweetser, Joe <JSweetser@xxxxxxxx> <JSweetser@xxxxxxxx>
*Cc:* oracle-l <oracle-l@xxxxxxxxxxxxx> <oracle-l@xxxxxxxxxxxxx>
*Subject:* Re: Quick (hopefully) pl/sql cursor question



If the cursor is implicit in procedure3a like:



FOR x IN (SELECT * FROM DUAL) LOOP

  --do some stuff here

  NULL;

END LOOP;



The cursor is initialized when the PLSQL engine goes into FOR ...LOOP
statement.



Cheers,

Jacek



On Fri, 27 Sep 2019 at 18:27, Sweetser, Joe <JSweetser@xxxxxxxx> wrote:

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.
--
//www.freelists.org/webpage/oracle-l
<https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.freelists.org%2Fwebpage%2Foracle-l&data=02%7C01%7CJSweetser%40icat.com%7C4591147b189b4a8788ec08d7437d8f25%7C5d3bf30e9adb4c17b2425c17523e6e5e%7C0%7C0%7C637052078865102165&sdata=ThSmnA9x4wsV1dprcQbs6k%2BZCZuupiYKNy9WU7xlp9k%3D&reserved=0>

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.



--









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.

Other related posts: