Unanswered: How to compile C program for stored procedure
I am converting the Sybase stored procedures to DB2 UDB v7.2.9 for Windows. There are some global variable like @@sid is not supported in DB2. I found the following code in Internet that may help to solve the problem. However, I don't know how to compile the C program. Please advise how can I compile the C program to a DLL file and where to put the DLL file. I am using the compiler GCC on windows to compile stored procedure.
create function GET_APPL_ID()
external name 'GET_APPL_ID!GET_APPL_ID'
language c parameter style db2sql
NOT DETERMINISTIC FENCED
NO FINAL CALL
I can compile the C program to DLL file now and put it into the right directory and the stored procedure also compiled successfully. However, when I call the function like this "SELECT GET_APPL_ID() FROM TABLEABC", the call was successful but no result returned. Is this correct? Do I need to generate a .sqc file for the C program and call the EMBPREP.BAT to create a bind file for the C program.
Originally posted by fprose
Included on your installation CD is a samples directory. In addition to some sample UDF's you will find the .BAT files required to compile and install a UDF.
BLDRTN.BAT invoke the compile process and may need to be modified to support GCC. I've never used GCC and the .BAT file works fine for Visual C++.
You will need to create a .DEF file.
EMBPREP.BAT is called to create a bind file.
Ultimately, your DLL goes in the function directory under your instance.
Since the documentation on this process sucks my suggestion is to look at the examples IBM has created under /samples - specifically UDF's.