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!

Help with lpad and trim ??

PJS5Aug 8 2007 — edited Aug 9 2007
Hi, I am using the call below to add leading zeros in a select statement and it works fine.
LPAD (TRIM (ta.commission), 3, '0') "phase_code"
i.e. our phase_codes are generally 1,2,3,4, etc but need to be extracted for another purpose as 001, 002, 003, 004 etc.
The problem is i have now discovered that we will also have phase_codes that are typically 106001, 107001, 108001 etc.
So I need to do something like;
If the number selected = 1,2,3,4, etc add zeros in the extract to make it 001, 002, 003, 004 etc like currently happens but If the number = 106001, 107001, 108001 extract it as is.
Any thoughts??
Cheers, Peter
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2007
Added on Aug 8 2007
11 comments
1,613 views