text datatype question
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Using version 7.3 , we are trying to write a esql/c program that will read the contents of a text file into a variable and then insert that value into a table . In Esql/C ,what variable type should I be declaring to hold the text to insert ? TIA
Michael Talbot wrote: > > Using version 7.3 , we are trying to write a esql/c program that will read > the contents of a text file into a variable and then insert that value into > a table . > > In Esql/C ,what variable type should I be declaring to hold the text to > insert ? In ESQL/C you can load a TEXT column three ways from a file, from memory, or using a set of user defined functions. You declare a type loc_t structure and fill in the appropriate fields in the structure to indicate which method you are using and the address(es) of the filename, data memory, or user functions. There are examples in the ESQL manual and sample code in the demo directory and also in several utilities available from the IIUG Software Repository such as Jonathan Leffler's sqlcmd utility and my dbcopy utility (package utils2_ak). -- Art S. Kagel & Family kagel@erols.com
"Art S. Kagel & Family" wrote: > Michael Talbot wrote: > > > > Using version 7.3 , we are trying to write a esql/c program that will read > > the contents of a text file into a variable and then insert that value into > > a table . > > > > In Esql/C ,what variable type should I be declaring to hold the text to > > insert ? > > In ESQL/C you can load a TEXT column three ways from a file, from > memory, or using a set of user defined functions. You declare a type > loc_t structure and fill in the appropriate fields in the structure to > indicate which method you are using and the address(es) of the > filename, data memory, or user functions. There are examples in the > ESQL manual and sample code in the demo directory and also in several > utilities available from the IIUG Software Repository such as Jonathan > Leffler's sqlcmd utility and my dbcopy utility (package utils2_ak). > And one of the programs bundled with SQLCMD is called UPDBLOB. Guess what it does? updblob -d dbase -t table -k serial_col=1234 text.file -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>
An addition or an asside. FWIW: The fastest method for inserting BLOBs is LOC_USER where you supply an open, close, and read or write function to handle getting the BLOB from where it is to the SQL buffers for transfer. In ESQL/C 5.xx & 6.00 LOC_FILE or LOC_FNAME (read from a file by handle or by name) was next fastest - so much so I had one app that actually wrote the BLOB to disk just so it could use LOC_FNAME instead of LOC_MEMORY. Since discovering that LOC_USER is fastest of all and not as hard to program as the manual seems to make it look, I have not tested to see if the LOC_MEMORY interface has improved in ESQL/C 7.xx or 9.xx (SDK 2.yy) so I do not know. One should experiment for apps that need performance and use the simplest method for less critical apps, ie if the BLOB data is on disk use LOC_FILE/LOC_FNAME if it is already in memory use LOC_MEMORY. Art S. Kagel "Art S. Kagel & Family" wrote: > Michael Talbot wrote: > > > > Using version 7.3 , we are trying to write a esql/c program that will read > > the contents of a text file into a variable and then insert that value into > > a table . > > > > In Esql/C ,what variable type should I be declaring to hold the text to > > insert ? > > In ESQL/C you can load a TEXT column three ways from a file, from > memory, or using a set of user defined functions. You declare a type > loc_t structure and fill in the appropriate fields in the structure to > indicate which method you are using and the address(es) of the > filename, data memory, or user functions. There are examples in the > ESQL manual and sample code in the demo directory and also in several > utilities available from the IIUG Software Repository such as Jonathan > Leffler's sqlcmd utility and my dbcopy utility (package utils2_ak). > > -- > Art S. Kagel & Family > kagel@erols.com