?
Solved

Avoid Blank Spaces for columns  While Spooling to Flat File

Posted on 2008-10-18
3
Medium Priority
?
667 Views
Last Modified: 2013-12-19
Hello,
I have to use spool to export data to flat file(.txt) in oracle.  These columns available in my table (TBL_JE_OUTPUT )
RECORD_TYPE,BUSINESSUNIT, JOURNALID,LEDGER,JOURNAL_LINE_NO, ACCOUNT- These are few columns in my table all are varchar2 type.
The columns like JournalID,Ledger,Jounrnal_line_no,Account are nullable. when I'm using a select query to spool data to text file - the columns having null value, the text file contains blank spaces for the columns which are null. Please find the example below.
SQL> set colsep ''
SQL> select RECORD_TYPE,BUSINESSUNIT, JOURNALID,LEDGER,JOURNAL_LINE_NO, ACCOUNT from tbl_je_output;

RBUSINJOURNALID LEDGER    JOURNAACCOUN
--------------------------------------
LADV01                    000005155110
LADV01                    000006155110
LADV01                    000007155110
LADV01                    000008155110
LADV01                    000009155110
LADV01                    000010155110
LADV01                    000011337016
HAFC01NEXT      ACTUALS
LAFC01                    000001152312
LAFC01                    000002
HAFC01NEXT      ACTUALS

But I want the output as under:
LADV01000005155110
LADV01000006155110
LADV01000007155110
LADV01000008155110
LADV01000009155110
LADV01000010155110
LADV01000011337016
HAFC01NEXTACTUALS
LAFC01000001152312
LAFC01000002
HAFC01NEXTACTUALS

How to achieve this? Please helpme out as this is an urgent requirement
0
Comment
Question by:msasikala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22747377
what about this:
 select RECORD_TYPE || BUSINESSUNIT ||  JOURNALID || LEDGER || JOURNAL_LINE_NO || ACCOUNT from tbl_je_output;

Open in new window

0
 
LVL 7

Expert Comment

by:DiscoNova
ID: 22747890
If simple concatenation of the fields is all that is required, angelIII's solution is the correct way to go. On the other hand, if the concatenated fields might consist of (leadin or trailing) whitespaces, you might need to do something like this:
select
  trim(RECORD_TYPE)
  ||
  trim(BUSINESSUNIT)
  ||
  trim(JOURNALID)
  ||
  trim(LEDGER)
  ||
  trim(JOURNAL_LINE_NO)
  ||
  trim(ACCOUNT)
from
  tbl_je_output;

Open in new window

0
 
LVL 7

Accepted Solution

by:
DiscoNova earned 375 total points
ID: 22747898
Oh yes... and if the fields might contain whitespace in some other part than their beginning or ending, you would need to use the translate-function (or something similar) to get rid of them.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question