Solved

Creating Fixed length Text file from Oracle 9i table.

Posted on 2008-10-30
4
962 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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

773 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