读书人

SQLBindParameter怎么绑定NULL值

发布时间: 2013-01-06 15:44:47 作者: rapoo

SQLBindParameter怎样绑定NULL值
对于表中的时间类型,当为空时,直接插入空字符串时会报错提示时间格式不正确,在SQL语句里能插入NULL值,我在C里面用SQLBindParameter该怎样绑定NULL值,写到时间类型的字段里?
SQL="INSERT CTEST (CLT_TIME) VALUES(?)"
parameter="2008-11-06 14:45:33.000000";

cliRC = SQLBindParameter(hstmt,
i,
SQL_PARAM_INPUT,
SQL_C_CHAR,
SQL_CHAR,
26,
0,
parameter,
0,
NULL);
当时间有值时,是可以插入的,当为空时,就不能插入,提示An invalid datetime format was detected; that is, an invalid string representation or value was specified. SQLSTATE=22007
我该怎么做?
谢谢
[解决办法]
Just Try:
------------------------
cliRC = SQLBindParameter(hstmt,
i,


SQL_PARAM_INPUT,
SQL_C_CHAR,
SQL_CHAR,
26,
0,
SQL_NULL_DATA, /* use this for test */
0,
NULL);

读书人网 >IBM DB2

热点推荐