#1: IMS application in C, accessing DB2 Author: gdenunzio, Posted: Tue Oct 28, 2003 2:32 pm Hi all!
After some learning in the IMS world (just the basics, so I can go on experimenting with application programming), I am now trying to write a transaction, coded in the C language, which uses SQL to talk to DB2.
The manual says that I have to insert this line in my code:
#pragma runopts(env(ims),plist(os))
but this causes some problems: #pragma runopts must be put at the very beginning of a source file, before any C instruction, and this is what I do. But my source code is pre-digested by the SQL pre-compiler, which inserts a lot of SQL stuff at the start of the file. So #pragma runopts in practice finds itself after a lot of C lines automatically inserted, and the compiler says:
WARNING EDC0440 SYS97301.T195758.RA000.DB2IMSMK.DSNHOUT.H01:24 #pragma runopts must appear before any C code.
Even if this is just a warning, I imagine that means that my options will not be taken into consideration..?
Moreover, I am not finding the exact meaning of that message (beside the obvious).
Any help? Any C source code which calls DB2?
Thanks!
Giorgio
#2: Author: kolusu, Location: San JosePosted: Tue Oct 28, 2003 3:04 pm Giorgio,
Check the following link for C/C++ program examples using DB2.
#3: Author: gdenunzio, Posted: Wed Oct 29, 2003 7:43 am Hi Kolusu!
Thanks for your kind reply!
I had already looked at that documentation (for older MVS/IMS/DB2 versions, so perhaps now it contains something more: I'll check that) but it did not solve my problem. Anyway, I now have a solution, more or less...
I resume; my source is split in three parts (in three different sources): main, doims, dosql. "Main" contains the ims runopt stuff, and calls the other two parts. Now, I simply don't let "main" pass through the SQL preprocessor (only dosql needs it). I do all steps separately (sql preprocessor only when needed, compiler, prelinker for all the objects together, linker) and all is working fine (at least as far as program preparation is concerned: now I have to see if DB2 calling works!!).
Of course I'd like to know if a more elegant solution, valid for a single-source program, exists.
Another (small) problem I have now is to see how I say to IMS that it has to reload the application program linked to a transaction, when I change this program: it is evident that IMS loads somewhere a copy of the module, so re-compiling it is not enough: I have to explicitly invalid the old copy and make ims accept the new one.
Thanks!
Giorgio