Re: for loop as text variable

From: jimmy <bigtoehere_at_hotmail.com>
Date: Fri, 21 Oct 2011 09:35:22 -0300
Message-ID: <f9p2a717kkip5397l8l2omfng20ka4f0dv_at_4ax.com>



On Thu, 20 Oct 2011 11:48:20 -0700 (PDT), Mark D Powell <Mark.Powell2_at_hp.com> wrote:

>On Oct 19, 9:31 am, jimmy <bigtoeh..._at_hotmail.com> wrote:
>> Hi.  I'm trying to use a varchar as the first part of a for loop but
>> can't find a way to make it work.  
>>
>>     listCursor     varchar2(100);
>>
>>     if x is not NULL then
>>        listCursor := 'for x_rec in xC(parm1, parm2) loop';
>>     else
>>        listCursor := 'for y_rec in yC(parm1, parm2) loop ';
>>     end if;
>>     print listCursor **** not sure of syntax here or if this is even
>> possible.
>>         ....
>>         ....
>>     end loop;
>>
>> Any suggestions?
>>
>> many thanks,
>> tony
>
>The dbms_output package can be used to write information to the screen
>for debugging purposes. See your PL/SQL Packages and Types manual for
>details. Example: dbms_output.put_line('sting ='||plsql_variable);
>The use of 'setserveroutput on' is required prior to use to see the
>output.

Noted, thanks.

>
>I am just going to assume you are writing some kind of code generator
>and not worry about how you intend to execute your cursor.

Good assumption. All I want to generate is the

  for x_rec in xC or yC (parm1, parm2) loop

part of the for loop syntax. The reason for this is we have an old, fairly large and unmodified package that now requires an additional slightly different select statement. If I could do this, nothing else needs to change. I do know I can use ref cursors but thought this would be much simpler if doable.

tony

>
>HTH -- Mark D Powell --
Received on Fri Oct 21 2011 - 07:35:22 CDT

Original text of this message