Declaring Host Variables with the db2dclgn Declaration Generator

You can use the Declaration Generator to generate declarations for a given table in a database. It creates embedded SQL declaration source files which you can easily insert into your applications. db2dclgn supports the C/C++, Java™, COBOL, and FORTRAN languages.

About this task

To generate declaration files, enter the db2dclgn command in the following format:
   db2dclgn -d database-name -t table-name [options]

For example, to generate the declarations for the STAFF table in the SAMPLE database in C in the output file staff.h, issue the following command:

   db2dclgn -d sample -t staff -l C

The resulting staff.h file contains:

     struct
     {
       short id;
       struct
       {
         short length;
         char data[9];
       } name;
       short dept;
       char job[6];
       short years;
       double salary;
       double comm;
     } staff;