Home » SQL & PL/SQL » SQL & PL/SQL » how to loop and duplicate a string (11G)
how to loop and duplicate a string [message #631077] Thu, 08 January 2015 19:58 Go to next message
kmmchan
Messages: 1
Registered: January 2015
Junior Member
hi experts

I have this string which I need to query from a table

select config_val from from config_tab where config_string = 'COLUMN_OUT'

CONFIG_VAL
----------
A_$,B_$,C_$,D_$

I need to loop through this string dynamically and replace the '$' with the actual looping value

e.g. If the loop=2, then the value should be A_1,B_1,C_1,D_1,A_2,B_2,C_2,D_2
if the loop=3, then the value should be A_1,B_1,C_1,D_1,A_2,B_2,C_2,D_2,A_3,B_3,C_3,D_3
and etc...

Any idea I can do this?
Re: how to loop and duplicate a string [message #631078 is a reply to message #631077] Thu, 08 January 2015 20:10 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum.

>Any idea I can do this?
do it with PL/SQL

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and read http://www.orafaq.com/forum/t/174502/

It is a rather simplistic homework assignment.
I suspect one of your co-workers could assist if you asked for assistance.
Re: how to loop and duplicate a string [message #631096 is a reply to message #631077] Fri, 09 January 2015 00:37 Go to previous message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

In SQL, you have to use a row generator.
REPLACE and LISTAGG functions will also be of some help.

[Updated on: Fri, 09 January 2015 02:54]

Report message to a moderator

Previous Topic: different outputs on same parameter (datatype date) while using 'like' and '='
Next Topic: calling proc with packag giving no output
Goto Forum:
  


Current Time: Wed Aug 26 09:58:38 CDT 2026