DB2 嵌入SQL 编译问题
时间:2010-08-10
来源:互联网
连接PAYMENTS数据库,查询用户为DOLORES的薪水是多少
程序如下:
复制代码
预编译出错:
db2 prep employee.sqc bindfile
LINE MESSAGES FOR employee.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
SQL1024N A database connection does not exist. //怎么会没有连接PAYMENTS数据库呢?
SQLSTATE=08003
SQL0095N No bind file was created because of previous
errors.
SQL0091W Precompilation or binding was ended with "2"
errors and "0" warnings.
程序如下:
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include "util.h"
- #include<sqlca.h>
- EXEC SQL INCLUDE SQLCA;
- main()
- {
- EXEC SQL BEGIN DECLARE SECTION;
- float salary;
- EXEC SQL END DECLARE SECTION;
- EXEC SQL CONNECT TO PAYMENTS;
- EXEC SQL SELECT SALARY INTO :salary
- FROM employee
- WHERE name='DOLORES';
- printf("salary=%f\n",salary);
- EXEC SQL CONNECT RESET;
- return 0;
- }
db2 prep employee.sqc bindfile
LINE MESSAGES FOR employee.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
SQL1024N A database connection does not exist. //怎么会没有连接PAYMENTS数据库呢?
SQLSTATE=08003
SQL0095N No bind file was created because of previous
errors.
SQL0091W Precompilation or binding was ended with "2"
errors and "0" warnings.
作者: addictlinux 发布时间: 2010-08-10
需要先执行下
db2 connect to PAYMENTS
然后在预编译、编译……
db2 connect to PAYMENTS
然后在预编译、编译……
作者: logicBaby 发布时间: 2010-08-10
step1: db2 connect to PAYMENTS
step2: db2 prep employee.sqc bindfile (employee.bnd employee.c)
step3: db2 bind employee.bnd
step4: gcc employee.c -L$HOME/sqllib/lib -ldb2 -o employee ( runs error)
the error message :
employee.c:20:21: error: sqladef.h: No such file or directory
employee.c:22: error: variable ‘sqla_rtinfo’ has initializer but incomplete type
employee.c:23: error: extra brace group at end of initializer
employee.c:23: error: (near initialization for ‘sqla_rtinfo’)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:23: error: ‘wchar_t’ undeclared here (not in a function)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:23: error: extra brace group at end of initializer
employee.c:23: error: (near initialization for ‘sqla_rtinfo’)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:26: error: ‘SQL_IS_LITERAL’ undeclared here (not in a function)
employee.c:27: error: ‘SQL_IS_INPUT_HVAR’ undeclared here (not in a function)
employee.sqc:4:18: error: util.h: No such file or directory
employee.sqc:5:18: error: sqlca.h: No such file or directory
employee.sqc: In function ‘main’:
employee.sqc:14: error: array type has incomplete element type
employee.sqc:17: error: array type has incomplete element type
step2: db2 prep employee.sqc bindfile (employee.bnd employee.c)
step3: db2 bind employee.bnd
step4: gcc employee.c -L$HOME/sqllib/lib -ldb2 -o employee ( runs error)
the error message :
employee.c:20:21: error: sqladef.h: No such file or directory
employee.c:22: error: variable ‘sqla_rtinfo’ has initializer but incomplete type
employee.c:23: error: extra brace group at end of initializer
employee.c:23: error: (near initialization for ‘sqla_rtinfo’)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:23: error: ‘wchar_t’ undeclared here (not in a function)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:23: error: extra brace group at end of initializer
employee.c:23: error: (near initialization for ‘sqla_rtinfo’)
employee.c:23: warning: excess elements in struct initializer
employee.c:23: warning: (near initialization for ‘sqla_rtinfo’)
employee.c:26: error: ‘SQL_IS_LITERAL’ undeclared here (not in a function)
employee.c:27: error: ‘SQL_IS_INPUT_HVAR’ undeclared here (not in a function)
employee.sqc:4:18: error: util.h: No such file or directory
employee.sqc:5:18: error: sqlca.h: No such file or directory
employee.sqc: In function ‘main’:
employee.sqc:14: error: array type has incomplete element type
employee.sqc:17: error: array type has incomplete element type
作者: addictlinux 发布时间: 2010-08-10
ls -l /home/db2inst1/sqllib/include/
-r--r--r-- 1 bin bin 5695 Nov 16 2009 asn.h
just only file asn.h !!!
NO OTHER FILES
my DB2 DATABASE : DB2-Express-C9.7.1
-r--r--r-- 1 bin bin 5695 Nov 16 2009 asn.h
just only file asn.h !!!
NO OTHER FILES
my DB2 DATABASE : DB2-Express-C9.7.1
作者: addictlinux 发布时间: 2010-08-10
# $DB2DIR的include目录下为何只有一个asn.h
原因是在安装db2的时候,可能选用了typical模式,则不会安装这些头文件。使用custom 模式,并在select features to install中选中SDK
原因是在安装db2的时候,可能选用了typical模式,则不会安装这些头文件。使用custom 模式,并在select features to install中选中SDK
作者: addictlinux 发布时间: 2010-08-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28