Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


URGENT How to export with PL/SQL, data from Oracle tables into DBF files

Posted on 2006-06-16
Medium Priority
Last Modified: 2007-12-19
I have the following problem:
I want to export, through PL/SQL, data from a Oracle table directly to a DBF file.

I think that is beeing done with UTL_FILE function, but i don't know how to write the DBF file header.

I want that export to happen at the user request from a form.
The file then will be e-mailed or put on a CD.

Another question: UTL_FILE put the file on the server (i'm using Oracle Database 9.2 and 9iAS 9.2). How to transfer automatically the file to the user's HDD?

2 questions, both hard, i think.

Please help if u have any informations, links, etc.
Question by:mitralier
  • 6
  • 6
  • 3
  • +2
LVL 16

Accepted Solution

MohanKNair earned 1000 total points
ID: 16918854
It is possible to read a dbase file using UTL_FILE and PL/SQL package. The package is available in the link below. The package can be modified to write in dbase format.

Xbase File Format Description is available in this link
LVL 25

Expert Comment

ID: 16920194
What kind of server do you have?  Unix or Windows?  Either way, the answer isn't simple.  How does the user access the database?  We have a web-based system that we access data through, and that system is responsible for FTPing files directly to users.  The database can't do that.

In your case, you can trigger an FTP from Oracle:

LVL 48

Assisted Solution

schwertner earned 1000 total points
ID: 16941186
The normal way to transfer data between different types of DBs are the flat files.
In Oracle you can do this either using UTL_FILE package
SQL>spool c:\some_file.txt
SQL>set heading 0
SQL> select name || ','||address from spme table;
SQL>spool off
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 48

Expert Comment

ID: 16941190
Second question; invoking ftp.

Author Comment

ID: 16948956
I've done, so far, the following
Using WebUtil for Oracle Forms i'v done a csv file directly from the database, that is saved directly on the client computer.

That's a problem solved for the tranfer of the file.

The remaining problem is how to write the DBF file, because it's a binary file and the header must be extremely exact.
If someone could help at this.............

At the end i will split the points, don't know exactly how :)

P.S. The FTP was not an option from the start, because of the security of the network. WebUtil it's the best for this, i think.
LVL 48

Expert Comment

ID: 16948983
Now using Excel create csv file (that is really character, not binary file) and try to read and insert the records into XBase system.

Author Comment

ID: 16950024
That's my problem schwertner, i don't know how to write in a dBASE system file.
I need a procedure that write the header and another procedure that write the actual data. I don't know what to use in any of them. The problem is that i will have to use WebUtil to build those procedures, because the file is written in Oracle Forms, not on a stored procedure.
LVL 48

Expert Comment

ID: 16950848
It is a bad idea to try 'to write in a dBASE system file'!
Every system has tools to read flat files and to put the records into the dbf files.
I personally did in 1997 the reverse task: In Clipper 5 I created flat file with Oracle "Insert" statements.
May be Dbase has its insert statement. If so it is easy to format the Oracle output to fit
the Dbase input.

Another option:

Data Loader is a simple yet powerful tool to import and export Data between many common formats. Current Data Loader Ver. 1.0 supports Oracle, MS Access, FoxPro, DBF's and Delimited or Flat Files. You can use Data Loader to transfer data from one database format to another database format. While transferring you can filter columns and specify WHERE conditions.
It supports Long , Picture Data types. In a jiffy you can copy data without any coding.
Supported O/s: Win 2003, Win 2000, XP, Win ME,Win98 &Win95

Author Comment

ID: 16951570
Ok, i think it's a misundersting here.

The actual problem is:

I have a form that call a stored procedure.
The stored procedure return the array with the data of the file.
The form writes the array into a .CSV file. For writing the file i use "client_text_io.putf" from WebUtil. That command create and write into a file on the client computer.

Now, i want that .CSV file to be a .DBF file, and after the export from my form to import it in FoxPro.
I don't know how to write the header of the DBF file and how to write the actual data. In CSV the data are comma delimited. In DBF.......HOW?


Author Comment

ID: 16951594
Oh, and i can't use a tool, the EXPORT it's gonna be integrated into an application, it's not for a one time use.
The user  will pick a table and then export it. I have that functionality, but the file is CSV. I want the file to be .DBF now.
LVL 16

Expert Comment

ID: 16967029
Instead of CSV file create a tab delimited file. This is accessible by Microsoft tools like excel.  
The comma character CSV file can be converted to TAB character by using another PL/SQL code.

Author Comment

ID: 16982498
I need a binary file, not a character file. Not tab delimited, comma delimited or any kind of delimited.
And i don't want to open it with Excel.
I want to open that file directly with FoxPro, after the export.
LVL 48

Expert Comment

ID: 16983908
There are such convertor programs, but most of them are paid.
Search using Google ...

Author Comment

ID: 16999107
Schwertner, i want to build such a program in PL/SQL and Forms, not using one.
LVL 48

Expert Comment

ID: 16999794
I see and understand. This is what I found:

How to Create a DBase File from Reports

Report Builder supports the following destination formats (DESFORMAT):
to create dBase file from Reports.

It is however possible to create DELIMITED report output and then
import/convert this to dBase. MS Excel can for example open delimited file and
then save the data as a *.DBF (dBase) file. This process (conversion from
delimited to *.dbf using MS Excel) can be automated using an OLE2 package.

Another method is to use the EXEC_SQL package to connect to ODBC data sources
(including dBase file) via the Open Client Adapter (OCA), which is supplied
with Developer. One can then programmatically manipulate that data source using
regular SQL statements (insert, update, delete, select). But Reports cannot
write it's output to such a datasource directly.

How to Obtain a Merant/Data Direct dBASE Driver for OFSA Import/Export

Importing and Exporting IDs

You can use import/export functionality of OFSA to:

  Transport IDs from one FDM database to another
  Maintain external backup copies of key IDs
  Load data into FDM from an external database (.DBF) source

OFSA provides two methods of importing and exporting IDs:
  Individual ID import/export
  Dependent ID import/export

Individual ID Import/Export

IDs that do not contain other embedded IDs, such as Leaf Characteristics ID and
Transfer Pricing ID, are imported and exported using the Individual ID method.
These IDs are exported into a dBase file with the.DBF extension and can be
imported only from a dBase file with the .DBF extension.

For OFSA 4.5.3 and Higher Versions:
Visit the following web site to purchase or download a trial version of the 32-
bit Data Direct dBase driver:


Go to:
-- "Download database drivers" (left side under Fast Access)
-- "DataDirect Connect for ODBC Windows"
-- Fill out form, selecting the following:
   --> Client workstation
   --> Under "Flat" files --> "dBASE"

After agreeing to the license agreement and hitting submit follow the download
instructions for "DataDirect Connect for ODBC 4.2 Windows Download".

Download the zip file for "Connect for ODBC Software for Windows, Windows
NT/2000/XP/Me/98 - Standard Pack" and double-click on the setup.exe to run
the install Wizard.  Choose to install a Desktop Single Driver.  Select the
dBASE driver.

For instructions on configuring the driver, please see  the following:
How to Setup 32-bit Merant/Data Direct dBASE Driver for Import and Export Functionality

For OFSA 4.5.2x and Lower Versions:
Use the 16-bit Merant/Data Direct Dbase Driver version 2.5.3 FA-dbase IV to
import and export OFSA IDs.

The 16-bit Merant/Data Direct Dbase Driver is no longer available for purchase.

If you already own the 16-bit Dbase driver, contact Data Direct to renew or add
more licenses.

To obtain a copy of the 16-bit Dbase driver software, a third-party vendor must
be located.  Look for vendors selling programmers and developers software and
tools and inquire about the 16-bit Merant dbase IV driver for Windows 3.x.

Note: The Merant driver was formerly known as the Intersolv driver.  It is now
called the Data Direct driver.

LVL 16

Expert Comment

ID: 16999852
See the link below. procedure dump_table in the package can be used to dump a file to disk in DBASE file format.



Expert Comment

ID: 20294463
Forced accept.

EE Admin

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
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 shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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

578 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