Solved

Oracle SQL: selecting integer values and returning them right padded and left justified

Posted on 2007-03-22
2
1,323 Views
Last Modified: 2009-12-16
Hi,
this might be an easy one: I'd like to select an integer data type, right pad with blanks so that there are 10 characters total and left-justify the output.

Example:
Select myInteger from table;
Should come out:
|999       |
(without the pipes but left justified and padded with blanks.

Thanks!
0
Comment
Question by:cxscheid
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 65 total points
ID: 18774542
Just use rpad.

Note: I added the pipes so you can see the padding.
-----------------------
drop table tab1;
create table tab1 ( col1 number );

insert into tab1 values(999);
commit;

select '|' || rpad(col1,10,' ') || '|' from tab1;
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 60 total points
ID: 18774550
select rpad(to_char(yourintegerfield),10,' ')
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question