Home » SQL & PL/SQL » SQL & PL/SQL » Column justify not working
Column justify not working [message #214135] Mon, 15 January 2007 01:59 Go to next message
attraxion
Messages: 14
Registered: October 2006
Junior Member
Hi All,

I got a rather wierd problem, one that I never faced before. I am trying to display a column that contains numerical values but has been designed as a varchar2. When I give these commands on SQLplus prompt:

SQL> COLUMN MANAGER_ID JUSTIFY RIGHT FORMAT A7
SQL> SELECT MANAGER_ID FROM PRODUCT;

The output is:

MANAGER
-------
80743
1001
180743
536
1783
562

As you can see, FORMAT A7 seems to be followed, but it is not right-justified. Similar thing happens when I give these commands in a script (*.sql) file. Please let me know what is wrong here.

I looked the COLUMN command syntaxes but nowhere does it mention any caveats with use of JUSTIFY. I also tried giving two COLUMN commands, one for A7 and one for JUSTIFY.

Thanks and regards,
Attraxion.
Re: Column justify not working [message #214153 is a reply to message #214135] Mon, 15 January 2007 03:11 Go to previous messageGo to next message
Littlefoot
Messages: 20896
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As you've already seen, storing numeric values into a character column isn't very good idea.

If there are all numbers in there, select TO_NUMBER(manager_id) and they will be right justified (no need for COLUMN settings).
Re: Column justify not working [message #214250 is a reply to message #214135] Mon, 15 January 2007 09:45 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
If you have a mixture of number and characters in a column, simply left pad. For example

col my_col heading 'column' format a10

select lpad(my_column,10,' ') my_col
from mytable;


Previous Topic: avoiding cross database links?
Next Topic: Finding most frequently occurring value
Goto Forum:
  


Current Time: Tue Dec 06 04:10:22 CST 2016

Total time taken to generate the page: 0.05241 seconds