Solved

Creating Fixed length Text file from Oracle 9i table.

Posted on 2008-10-30
4
957 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
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

744 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

8 Experts available now in Live!

Get 1:1 Help Now