?
Solved

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

Posted on 2007-03-22
2
Medium Priority
?
1,346 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 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 260 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 240 total points
ID: 18774550
select rpad(to_char(yourintegerfield),10,' ')
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 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