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!

lpad .. correct use to right justify a char field?

Ramky99Apr 18 2008 — edited Apr 19 2008
Hi all,

I have a column that's a char type, and I'm trying to manipulate justification within it.

SQL> create table test (test char(14));

Table created.

SQL> insert into test values (' 001234567890');

1 row created.

SQL> select * from test;

TEST
--------------
001234567890

..I have no probs making it left justified using ltrim

SQL> update test set test=ltrim(test);

1 row updated.

SQL> select * from test;

TEST
--------------
001234567890

...but when I try to right justify using lpad I can't get it to work:

SQL> update test set test=lpad(test,14,' ');

1 row updated.

SQL> select * from test;

TEST
--------------
001234567890

..this should pad the column with blanks to make the string 14 in length right?

What am I doing wrong?

Thanks !
Adam
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2008
Added on Apr 18 2008
7 comments
9,999 views