Home » SQL & PL/SQL » SQL & PL/SQL » Sql Satement print list of string (11.2.0.3,Linux X86_64)
Sql Satement print list of string [message #628347] Mon, 24 November 2014 06:54 Go to next message
preet_kumar
Messages: 204
Registered: March 2007
Senior Member
With the below statement i can print sequence of 1 till 20

select level from dual connect by level <= 20;

Is it possible to print something like below with a sql and using regexp? e.g in bash echo {a,b}{1..10}

a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10
Re: Sql Satement print list of string [message #628349 is a reply to message #628347] Mon, 24 November 2014 07:05 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Why use regular expressions?

select chr(65 + floor(rownum/10))||to_char(mod(rownum,10)) from dual connect by level <= 20;

[Updated on: Mon, 24 November 2014 07:06]

Report message to a moderator

Re: Sql Satement print list of string [message #628351 is a reply to message #628349] Mon, 24 November 2014 07:11 Go to previous messageGo to next message
preet_kumar
Messages: 204
Registered: March 2007
Senior Member
Whats other option other than regular expressions?
Re: Sql Satement print list of string [message #628352 is a reply to message #628351] Mon, 24 November 2014 07:13 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Rolling Eyes
Re: Sql Satement print list of string [message #628359 is a reply to message #628352] Mon, 24 November 2014 08:08 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Do you really think John posted some code that had nothing to do with your problem?
Re: Sql Satement print list of string [message #628360 is a reply to message #628359] Mon, 24 November 2014 08:19 Go to previous messageGo to next message
preet_kumar
Messages: 204
Registered: March 2007
Senior Member
Thanks John for your response and the select statement.

@John
The reason for me to think of regexp is because this may not work if i have to front something with zero prefix 00..10
echo {a,b}{00..10}
a00 a01 a02 a03 a04 a05 a06 a07 a08 a09 a10 b00 b01 b02 b03 b04 b05 b06 b07 b08 b09 b10
Re: Sql Satement print list of string [message #628361 is a reply to message #628360] Mon, 24 November 2014 08:23 Go to previous message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
So use your brain, and have a go.
Previous Topic: Oracle Regular Expression
Next Topic: divisor is equal to zero error
Goto Forum:
  


Current Time: Thu Apr 25 14:59:49 CDT 2024