This article mainly describes the two problems of compiling a DB2 database in C Language). If you compile a DB2 database in C language ), if you are interested, you can click the following article to view it. I hope it will help you in this regard.
DB2 C language compilation, expert
I now have two problems with DB2 compilation in C language)
1. 64-bit Compilation
In makefile, the database linked to db2 points to a 64-bit database, and the CC parameter specifies-q64 for compilation,
Prompt "The typedef definition of wchar_t is incompatible with the option wchar_t_size"
The difference between 32-bit and 64-bit is found. Ignore this error. when running the program, all database variables (sqlca. sqlcode)
A value is a random value. For example, if the error code is-303, it must be-303, but its value is 538976288.
When the makefile library points to 32 and the cc compilation parameter is changed to-q32, the above problem is solved.
Currently, DB2 database compilation must be performed in 64-Bit mode as required. What should I do to solve the above conflicts?
2. Type Mismatch
Define the corresponding macro in the *. h file according to the database table structure. If the field type in the structure is int or long,
When I define the variable type as int, the following error is prompted:
- The token "int" found in a host variable declaration is not valid
Obviously, this error indicates that int is invalid. Just change it.
When you modify all int type long, the following message is displayed:
- The 'long' host variable "fieldnum" is not valid.Use 'sqlint32' instead。
Since the current machine is 64-bit, I changed the long type to sqlint32 or sqlint64 in a unified manner. DB2 database compilation passes
However, an error with the error code 303 is prompted during execution, that is, the type does not match:
- SQL0303N A value cannot be assigned to a host variable in the
- SELECT, VALUES, or FETCH statement because the data
- types are not compatible.
In the hfile, sqlint32 or sqlint64 variables are defined as int type in the database.
The above content is the C language for the compilation of the DB2 database). The DB2 experts can provide a description of the problem and hope to help you in this regard.