Monday, November 15, 2004

PreCompiling and Running Embeded SQL

Write your Embeded SQL C code with a file extension .sqc

Precompiling

db2 connect to database name
db2 prep filename.sqc
db2 connect reset

The Above Command on Sucess will give a filename.c file.

The C File needs to compilied with special flags as follows

gcc filename.c -Wall -I/home/db2inst1/sqllib/include/ -L/home/db2inst1/sqllib/lib -ldb2 -Wl,-rpath,/opt/IBM/db2/V8.1/lib -o

Run the outputfile to see the results.


NOTE:
  • The flags may vary if you have a username other than db2inst1.
  • And the flags need to be properly spaced.

No comments: