Solved

Creating Fixed length Text file from Oracle 9i table.

Posted on 2008-10-30
4
959 Views
Last Modified: 2013-12-19
Hi,
  I am trying to generate a fixed length text file from Oracle 9i table.
Ex:
  My expected output is
  Positon       Field
  1-10           First Name
  11-20         Last Name
   20-40        Address
My output is going to look like this:
Steveson  Cathy     Washington DC
Robbs       Valles    Maryland

What is best way i can do, UTL_FILE or Spool or some other approach? If so how to do?

Thanks.
0
Comment
Question by:jainulap
4 Comments
 
LVL 27

Accepted Solution

by:
sujith80 earned 30 total points
ID: 22847497
spool approach.

set heading off
set pages 0
set echo off

select rpad(firstName,10)||rpad(lastName,10)||rpad(address,20)
from <table>;
0
 
LVL 9

Expert Comment

by:MarkusId
ID: 22848449
Or you can define columns (also spool, the rpad-approach wou8ld also work with utl_file)

set heading off
set pages 0
set echo off
set trimspool on
col firstName format a10
col lastName format a10
col address format a20

spool filename

select firstName, lastName, address
from <table>;

spool off

Have also a look at http://www.psoug.org/reference/sqlplus.html about the possibilities of column-formatting in Oracle
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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 configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

929 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now