Solved

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

Posted on 2007-03-22
2
1,302 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 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 65 total points
Comment Utility
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 31

Assisted Solution

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now