Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Filling Substring with Spaces..!

500894Mar 12 2007 — edited Mar 13 2007
Hi,

I have a requirement where i have to fill a string which is having
specific length with spaces and the result should have the same
number of spaces as the characters in the string..!

In my case the string is a numeric one..!

My program is as follows ...

But i am not getting the desired output..!

declare
l_sstr varchar2(11) := '12345678901';
l_mstr varchar2(11);
l_len number;
begin
l_len := length(l_sstr);
for i in 1..l_len
loop
l_mstr := l_mstr||translate(substr(l_sstr,i,1),'1234567890',CHR(32));
dbms_output.put_line(l_mstr);
dbms_output.put_line('length'||length(l_mstr));
end loop;
dbms_output.put_line('string'||l_mstr);
--dbms_output.put_line('length'||length(l_mstr));
end;

Thanks in Advance..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2007
Added on Mar 12 2007
11 comments
1,648 views