pl/sql [message #304444] |
Wed, 05 March 2008 04:04 |
vinaya.v
Messages: 8 Registered: March 2008
|
Junior Member |
|
|
1.how to reverse the numbers using pl/sql
for eg
input is 78987345
output should be 54378987
2.how to store values in an array.
3.wat is an varray
|
|
|
|
|
|
Re: pl/sql [message #304477 is a reply to message #304467] |
Wed, 05 March 2008 06:18 |
dhananjay
Messages: 635 Registered: March 2002 Location: Mumbai
|
Senior Member |
|
|
using sql to reverse the number:
you can make use of the SUBSTR()to generate a row and then use SYS_CONNECT_BY_PATH().
regards,
|
|
|
|
Re: pl/sql [message #304650 is a reply to message #304444] |
Thu, 06 March 2008 00:44 |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
SQL> ed
Wrote file afiedt.buf
1 declare
2 inputstring varchar2(100) :='78987345';
3 outputstring varchar2(1);
4 n number;
5 begin
6 for n in 1..length(inputstring)
7 loop
8 select substr(inputstring,length(inputstring)-n+1,1) into outputstring from dual;
9 dbms_output.put(outputstring);
10 end loop;
11 dbms_output.put_line(' ');
12* end;
SQL> /
54378987
PL/SQL procedure successfully completed.
regards,
|
|
|
|
Re: pl/sql [message #304710 is a reply to message #304444] |
Thu, 06 March 2008 05:46 |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
SQL> ed
Wrote file afiedt.buf
1 declare
2 input number :=78987345;
3 output number(1);
4 n number;
5 begin
6 for n in 1..length(input)
7 loop
8 select substr(input,length(input)-n+1,1) into output from dual;
9 dbms_output.put(output);
10 end loop;
11 dbms_output.put_line(' ');
12* end;
SQL> /
54378987
PL/SQL procedure successfully completed.
regards,
|
|
|
Re: pl/sql [message #304714 is a reply to message #304710] |
Thu, 06 March 2008 05:54 |
|
Michel Cadot
Messages: 68728 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
"length" takes a string as (first) parameter as well as "substr".
NEVER rely on implicit conversion.
Regards
Michel
|
|
|