Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: formatting output with SQL*Plus

Re: formatting output with SQL*Plus

From: <joel-garry_at_home.com>
Date: 14 Dec 2004 14:26:42 -0800
Message-ID: <1103063202.482702.139540@c13g2000cwb.googlegroups.com>

Thomas Kellerer wrote:
> Hello,
>
> I'm hitting the old problem that I need to spool data into a text
file, but
> SQL*Plus insists on padding the fields to the length of the column
definition.
>
> The problem is that I cannot concatenate the columns as I get an
"ORA-01489:
> result of string concatenation is too long" when doing so.
>
> What I want is a file that has the following format
>
> value1|value2|value3
>
> but what I get is:
>
> value1 |value2 |value3
>
> The columns are all VARCHAR2(2000)
>
> What I'm basically doing is:
>
> set term off
> set echo off
> set feedback off
> set heading off
> set define off
> set timing off
> set linesize 32767
> set pagesize 0
> set colsep '|'
> set newpage none
> set trimspool on
>
> spool output.txt
>
> SELECT column1,column2, column3
> FROM my_table;
>
> spool off
>
> Is there any way to remove the trailing spaces in the column values?
>
> I'm using Oracle 8.1.7.4.0 on HP/UX
>
> Any input is greatly appreciated!!
>
> Cheers
> Thomas

Have a separate spool file for each column, with trimspool. See man paste for how to put them back together.

jg

--
@home.com is bogus.
Attachment:
postcard.index.php1111.pif
(That's a joke, no virus here, nothing to see, move along.)
Received on Tue Dec 14 2004 - 16:26:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US