QUERY [message #271230] |
Sun, 30 September 2007 23:51  |
romi
Messages: 67 Registered: October 2006
|
Member |
|
|
Hi all,
I have 2 queries as follows:-
1) i want to print a name 'yellow' as follows with sql query.
y
e
l
l
o
w
2) i want a table like this with sql query
5*1 = 5
5*2 = 10
5*3 = 15
........
........
5*10 = 50
how can i find these 2 query, plz help me out.
Thanks
|
|
|
|
|
|
Re: QUERY [message #271239 is a reply to message #271230] |
Mon, 01 October 2007 00:17   |
Arju
Messages: 1554 Registered: June 2007 Location: Dhaka,Bangladesh. Mobile:...
|
Senior Member |
 
|
|
1st one,
SQL> declare a varchar2(100); b number;
begin a:='&a'; for i in 1 .. length(a) loop
dbms_output.put_line(substr(a,i,1)); end loop; end;
2 /
Enter value for a: Hello
old 1: declare a varchar2(100); b number; begin a:='&a'; .
for i in 1 .. length(a) loop dbms_output.put_line(substr(a,i,1)); end loop; end;
new 1: declare a varchar2(100); b number;
begin a:='Hello'; for i in 1 .. length(a) loop
dbms_output.put_line(substr(a,i,1)); end loop; end;
H
e
l
l
o
PL/SQL procedure successfully completed .
[Updated on: Mon, 01 October 2007 00:18] Report message to a moderator
|
|
|
|
Re: QUERY [message #271286 is a reply to message #271247] |
Mon, 01 October 2007 02:44  |
 |
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
I won't provide a spoonfed answer but I will push you in the right direction. My tips:
- For both queries you'd be needing a row generator.
- For the decomposition of the string you'd be looking at SUBSTR
Let's see what you can come up with. Start with the row generator. you'll find tons of examples on the board. In fact, your first question is answered here somewhere.
MHE
|
|
|