Re: Can a 4GL program read an ASCII file?
Posted in 1994
HoopsCraz (hoopscraz@aol.com) wrote:
: I'm trying to create a process that will read in an ASCII file one record
: at a time and update appropriate tables based on a key. The ASCII file
: consists transaction headers that may have one or many detail lines
: following them.
: My question is this: Is it possible for a 4GL program to read directly
: from
: an ASCII file? I have looked briefly at using a C program, would this be
: the
: solution to choose, using PUSH and POP?
: Any suggestions would be appreciated.
Nick, I've done it both ways, using load or dbload in some cases and custom
C functions in others. The best solution depends on whether load/dbload
provide enough flexibility and error handling for you, and on how comfortable
you are with developing and maintaining Informix functions in C.
If your ASCII file contains different record types you can preprocess it
with a script language like awk or perl into a format that dbload can
handle. There will have to be a permanent table created for this purpose.
The 4GL LOAD statement tends to be a poor substitute for dbload because
it has no error recovery and it tries to accompish the load in a single
transaction.
On the other hand, with C functions you may be able to do any with the
intermediate tables and process a complex ASCII file directly into the
4GL program. This is trickier but the results sometimes justify the
means. Once I wrote an import process that had to read raw data files
about 20MB in size, and run every week. To maximize performance we
eliminated the retint/retquote functions and wrote directly to 4GL
global variables. This is possible if you stick with c4gl and declare
the global variables carefully. We were able to cut our processing
time by around 90%.
There are many ways to solve this problem. I'd say use the simplest
method that meets your requirements.
--
Jeff Sturm