Re: HOW TO PREPARE A LOAD STATEMENT
Posted in 1995
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Migration, Import/Export & Data Conversion
Oops ... sorry about the aborted message. No, as you demonstrated, and as the manual documented, the LOAD and UNLOAD statements are not preparable. As to work-arounds, you have a variety of options. FUNCTION loadtable(file, table) DEFINE file char(30), table char(18) CASE table WHEN "table1" LOAD FROM file INSERT INTO Table1 WHEN "table2" LOAD FROM file INSERT INTO Table2 [...] OTHERWISE ERROR "Unknown Table <<", table CLIPPED, ">>" END CASE END FUNCTION Alternatively, you can investigate the generated C code and make use of the reverse engineering in writing your own program -- no, I'm not going to do it for you, but it isn't hard; and, with care, it can be applied to both c-code and p-code. Alternatively, you could run a program to do the loading. I'd use my own sqlreload command (part of SQLCMD in the c.d.i archives) which takes a database, a table and a file name as arguments and does the load for me, but you could arrange to use a shell script which uses ISQL or DB-Access, or whatever else takes your fancy. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: It is a great help to have an explanation of 'this is what I really want to do' -- it makes it much easier to provide answers. >Date: Mon, 4 Dec 95 16:07:16 GMT >From: dilip kumar biswal <dil@psi.ernet.in> >X-Informix-List-Id: <list.8129> > > May I know from you whether a load/unload statement can be prepared ? > >ATTEMPT : > PREPARE load_stmt FROM "LOAD FROM ? INSERT INTO ?" > >RESULT : > Error no 201 encountered. >The mannual also says that it is impossible to prepare a LOAD stmt. > >The requirement is : > I receive unloaded ascii files from different branch offices of a bank >and I want to load them to their respective tables through a 4GL program. > >Is there any work arounds ?