dbTalk Databases Forums  

Leading spaces in a spooled select

comp.databases.oracle.tools comp.databases.oracle.tools


Discuss Leading spaces in a spooled select in the comp.databases.oracle.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
snarks@gmail.com
 
Posts: n/a

Default Leading spaces in a spooled select - 09-07-2007 , 06:04 AM






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.


Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: Leading spaces in a spooled select - 09-07-2007 , 11:31 AM






snarks (AT) gmail (DOT) com wrote:
Quote:
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@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.