Loading data from a text file Informix

4.9k views Asked by At

I want to know if there is any other way to load data from a text file other than using external tables.

Text file looks something like

101 fname1 lname1 D01..
102 fname2 lname2 D02..

I want to load it into a table with columns emp_id, fname, lname, dept etc.

Thanks!

2

There are 2 answers

0
Michał Niklas On BEST ANSWER

As ceinmart suggested in comments you can do it from server side or from client side. From server side you can use DB-Access and LOAD command. From client side you can use any tool you like. For such tasks I often use Jython that can use Python string and CSV libraries as well as JDBC database drivers. With Jython you can use csv module to read data from file and PreparedStatement to insert it into database. In my other answer: Substring in Informix you will see such PreparedStatement.

0
FanDeLaU On

There are three utilities in Informix to load data to the database from flat files:

Load SQL command. Very simple to use, but not very flexible. I would recommend this for small amounts of records (less than 10k)

Dbload, which is a command line utility, a bit more complex than the load sql command. This will allow you to have more control on how the records are loaded: commit intervals, starting point in the flat file, number of errors before exiting, etc. I'd recommend this utility for a small to medium sized data loads (>10k<100k).

HPL, or High Performance Loader, which is a rather complex utility that can load data at a very high rate of speed, but with a lot of overhead. Recommended for large to x-large data loads.