Re: for loop as text variable
From: Mark D Powell <Mark.Powell2_at_hp.com>
Date: Thu, 20 Oct 2011 11:48:20 -0700 (PDT)
Message-ID: <949b7d4f-5416-444b-8691-f6d2f7acdde5_at_i19g2000yqa.googlegroups.com>
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
Date: Thu, 20 Oct 2011 11:48:20 -0700 (PDT)
Message-ID: <949b7d4f-5416-444b-8691-f6d2f7acdde5_at_i19g2000yqa.googlegroups.com>
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.
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.
HTH -- Mark D Powell -- Received on Thu Oct 20 2011 - 13:48:20 CDT