Avoid Blank Spaces for columns While Spooling to Flat File

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
msasikalaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Open in new window

0
DiscoNovaCommented:
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
DiscoNovaCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.