Re: Leading spaces in a spooled select

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 07 Sep 2007 09:31:52 -0700
Message-ID: <1189182705.611946_at_bubbleator.drizzle.com>


snarks_at_gmail.com wrote:
> Here's my SQL*Plus program:
>
> SET SPACE 0
> SET LINESIZE 4000
> SET TRIMSPOOL ON
> -- This must be a single 'tab' character, not a space
> SET COLSEP ' '
> SET PAGESIZE 0
> SET ECHO OFF
> SET FEEDBACK OFF
> SET VERIFY OFF
> SET HEADING OFF
> SET MARKUP HTML OFF SPOOL OFF
> SET SERVEROUTPUT ON
> SET TERMOUT OFF
> SPOOL Output.txt
> SELECT numeric_field
> , character_field
> FROM data_source;
>
> What I want is a tab-separated text file. The problem is that the
> numeric field ends up with leading spaces. I've tried SELECT
> TRIM(numeric_field) but then it just ends up with a load of trailing
> spaces, which is odd. I'm getting around it by using the || operator
> to concatenate the tabs manually. How do I get rid of the leading and/
> or trailing spaces on the first field?
>
> Phil Hibbs.

Convert numeric to string where you can use pad and trim. Concatenate in CHR(09) for tabs.
for tabs.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Fri Sep 07 2007 - 18:31:52 CEST

Original text of this message