dbTalk Databases Forums  

for loop as text variable

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss for loop as text variable in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jimmy
 
Posts: n/a

Default for loop as text variable - 10-19-2011 , 08:31 AM






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

Reply With Quote
  #2  
Old   
Mark D Powell
 
Posts: n/a

Default Re: for loop as text variable - 10-20-2011 , 01:48 PM






On Oct 19, 9:31*am, jimmy <bigtoeh... (AT) hotmail (DOT) com> wrote:
Quote:
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 --

Reply With Quote
  #3  
Old   
jimmy
 
Posts: n/a

Default Re: for loop as text variable - 10-21-2011 , 07:35 AM



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

Quote:
On Oct 19, 9:31*am, jimmy <bigtoeh... (AT) hotmail (DOT) 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.

Quote:
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

Quote:
HTH -- Mark D Powell --

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.