RE: need to trim spaces from sqlplus output

  • From: "Dunbar, Norman (Capgemini)" <norman.dunbar.capgemini@xxxxxxxxxxxxxxxxxxxxxxxxx>
  • To: "Andrew Kerber" <andrew.kerber@xxxxxxxxx>, <Joel.Patterson@xxxxxxxxxxx>
  • Date: Wed, 19 Jan 2011 16:44:56 -0000

Hmmm,

it appears that my test was slightly (!) inaccurate! 



Using this instead:

SQL> col a format 999
SQL> col b format a20
SQL> col c format a1

SQL> select eng_id as a, eng_name as b, 'c' as c from rota_engineer

   A|B                   |C
----|--------------------|-
  18|NORMAN DUNBAR 1     |c
   2|NORMAN DUNBAR 2     |c
  12|NORMAN DUNBAR 3     |c
  19|NORMAN DUNBAR 4     |c
  14|NORMAN DUNBAR 5     |c
  16|NORMAN DUNBAR 6     |c

It seems that colsep is not the original problem. My apologies for a bad
test that looked like it solved the problem. :-(

Given that the width of each column is going to be the maximum width of
the data (or a column specifier as I have used above) then spaces either
top the left or right (or both) are probably going to be almost
certainly present.

(Column A above has leading spaces as I type this, however, there's no
telling what Outlook will do!)

Interestingly, numeric columns seem to get an extra leading space
regardless of the format specified. This is true on first, middle or
trailing columns in a query - I've tested that!

So, it appears as if your sed script to trim out the spaces is the best
bet.

Once again, apologies for a bad test.


Cheers,
Norm.

Norman Dunbar
Contract Senior Oracle DBA
Capgemini Database Team (EA)
Internal : 7 28 2051
External : 0113 231 2051 


Information in this message may be confidential and may be legally privileged. 
If you have received this message by mistake, please notify the sender 
immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should 
still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under 
the Freedom of Information Act, Data Protection Act or for litigation.  Email 
messages and attachments sent to or from any Environment Agency address may 
also be accessed by someone other than the sender or recipient, for business 
purposes.

If we have sent you information and you wish to use it please read our terms 
and conditions which you can get by calling us on 08708 506 506.  Find out more 
about the Environment Agency at www.environment-agency.gov.uk
--
//www.freelists.org/webpage/oracle-l


Other related posts: