lpad .. correct use to right justify a char field?
Ramky99Apr 18 2008 — edited Apr 19 2008Hi 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