Solved

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

Posted on 2007-03-22
2
1,327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
create a nested synonym 4 54
error in my cursor 5 57
return value in based on value passed 6 48
Migration from SQL server to oracle (XML input) 4 65
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…
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 explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

739 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