[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

656 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