Successful read of ASCII from 4GL - fglgets()
Posted in 1994
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Migration, Import/Export & Data Conversion
>> 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. Thanks for all who responded with help on this problem. I couldn't use awk because I needed to insert header records, then use a serial column from that new row as a key for other table inserts. Here is the solution I ended up using, which I was able to compile under c4gl and also build a new fglgo runner... A function fglgets() is given in Chap 13 (pp 307 - 315) of "Informix 4GL by Example, v4.10". Earlier pages in the chapter explain how to compile it under various enviornments. With it you can have up to 8 ASCII files simultaneously open and being read (a little overkill). Your 4GL program can manupilate the data as it sees fit. I took this function one step further, and created a function fglputs(), which is almost identical. It is passed two parameters: filename and string, and does a puts to that file. This will allow our programers to write out customized unloads in a format that a mainframe can deal with (variables in a constant length format instead of clipping them, without delimeters, structured with header and detail records, etc.). The files we are using are not extremely large, but an interresting solution to cut run time was mentioned, if using c4gl: eliminate the retint/retquote functions and write directly to 4gl global vars.