otl与interval、绑定变量能否一起用解决思路
otl与interval、绑定变量能否一起用
在vc环境下采用otl更新数据库,代码如下:
char g_dbstr[256],sSql[1024];
memset(g_dbstr,0,sizeof(g_dbstr));
memset(sSql,0,sizeof(sSql));
sprintf(g_dbstr,"dnd/dnd@ora9_204");
string updateTime="20100415161712",hour="0",mimu="2",UserID="66660099";
connectToDB(g_dbstr);
sprintf(sSql,"update DND_User set UpdateEndDate = to_date ( :Update_Time<char[256]> , 'yyyy-mm-dd hh24:mi:ss' ) + interval :KeepTimeHH<char[256]> hour + interval :KeepTimeMM<char[256]> MINUTE where MSISDN = :UserID<char[256]> and ( ServiceType = 2 or ServiceType = 1) ");
otl_stream sqlstream(100,sSql,g_dbConn);
sqlstream<<updateTime.c_str()<<hour.c_str()<<mimu.c_str()<<UserID.c_str();
执行出现错误:
ORA-00933: SQL command not properly ended
如果把sql语句改成“update DND_User set UpdateEndDate = to_date ( :Update_Time<char[256]> , 'yyyy-mm-dd hh24:mi:ss' ) where MSISDN = :UserID<char[256]> and ( ServiceType = 2 or ServiceType = 1)”执行成功,
把sql语句改成"update DND_User set UpdateEndDate = to_date ( '20100415161712' , 'yyyy-mm-dd hh24:mi:ss' ) + interval '0' hour + interval '2' MINUTE where MSISDN = '66660099' and ( ServiceType = 2 or ServiceType = 1 )"执行成功,
把sql语句改成”update DND_User set UpdateEndDate = to_date ( :Update_Time<char[256]> , 'yyyy-mm-dd hh24:mi:ss' ) + interval '0' hour + interval '2' MINUTE where MSISDN = :UserID<char[256]> and ( ServiceType = 2 or ServiceType = 1)“执行成功
这是为什么呢?难道otl与interval、绑定变量不能一起用?
------解决方案--------------------
眼晕,帮你顶下吧!
在vc环境下采用otl更新数据库,代码如下:
char g_dbstr[256],sSql[1024];
memset(g_dbstr,0,sizeof(g_dbstr));
memset(sSql,0,sizeof(sSql));
sprintf(g_dbstr,"dnd/dnd@ora9_204");
string updateTime="20100415161712",hour="0",mimu="2",UserID="66660099";
connectToDB(g_dbstr);
sprintf(sSql,"update DND_User set UpdateEndDate = to_date ( :Update_Time<char[256]> , 'yyyy-mm-dd hh24:mi:ss' ) + interval :KeepTimeHH<char[256]> hour + interval :KeepTimeMM<char[256]> MINUTE where MSISDN = :UserID<char[256]> and ( ServiceType = 2 or ServiceType = 1) ");
otl_stream sqlstream(100,sSql,g_dbConn);
sqlstream<<updateTime.c_str()<<hour.c_str()<<mimu.c_str()<<UserID.c_str();
执行出现错误:
ORA-00933: SQL command not properly ended
如果把sql语句改成“update DND_User set UpdateEndDate = to_date ( :Update_Time<char[256]> , 'yyyy-mm-dd hh24:mi:ss' ) where MSISDN = :UserID<char[256]> and ( ServiceType = 2 or ServiceType = 1)”执行成功,
把sql语句改成"update DND_User set UpdateEndDate = to_date ( '20100415161712' , 'yyyy-mm-dd hh24:mi:ss' ) + interval '0' hour + interval '2' MINUTE where MSISDN = '66660099' and ( ServiceType = 2 or ServiceType = 1 )"执行成功,
把sql语句改成”update DND_User set UpdateEndDate = to_date ( :Update_Time<char[256]> , 'yyyy-mm-dd hh24:mi:ss' ) + interval '0' hour + interval '2' MINUTE where MSISDN = :UserID<char[256]> and ( ServiceType = 2 or ServiceType = 1)“执行成功
这是为什么呢?难道otl与interval、绑定变量不能一起用?
------解决方案--------------------
眼晕,帮你顶下吧!