出现Oracle ORA-24343的一种情况

    对于Oracle ORA-24343这种错误,Oracle的官方解释是:

 

Error Message: ORA-24343 user defined callback error

Error Cause:

The only valid return value for a user defined callback function is OCI_ CONTINUE. Any other value will cause this error.

Action:

Make sure that OCI_CONTINUE is returned from the user-defined callback function.

 

最近用Pro*C编写访问Oracle的数据库的程序,遇到了这个错误,最后发现导致这个错误的一个原因是

   “宿主变量”的长度分配不够。

 

如:

    EXEC SQL BEGIN DECLARE SECTION;

        char completion_time[30];
        char completion_time2[30];
        char SQLSTR[500];
    EXEC SQL END DECLARE SECTION;   

 

 string SQL = "select to_char(SWITCH.scan_start_time,'YYYY-MM-DD HH24:MI:SS'), (SWITCH.innho_att - SWITCH.innho_fail) / SWITCH.innho_att, (SWITCH.extin_att + SWITCH.extou_att - SWITCH.extin_fail - SWITCH.extou_fail) / (SWITCH.extin_att + SWITCH.extou_att) from u_msc_h_ho@pmdb SWITCH where SWITCH.mscname = :equipe_name and (SWITCH.scan_start_time between to_date(:completion_time, 'YYYY-MM-DD HH24:MI:SS') and to_date(:completion_time, 'YYYY-MM-DD HH24:MI:SS') + 13) and SWITCH.innho_att is not null and SWITCH.innho_fail is not null and SWITCH.extin_att is not null and SWITCH.extin_fail is not null and SWITCH.extou_att is not null and SWITCH.extou_fail is not null and SWITCH.extin_att + SWITCH.extou_att != 0 and SWITCH.innho_att != 0 and to_char(SWITCH.scan_start_time, 'HH24') in ('08','09','10','11','18','19','20','21') ";
   
    strcpy(SQLSTR, SQL.c_str());
   
    EXEC SQL PREPARE SQLCursor FROM :SQLSTR;
    EXEC SQL DECLARE GetSwitchSceneDataCursor CURSOR for SQLCursor;
   
    EXEC SQL OPEN GetSwitchSceneDataCursor using :equipe_name, :completion_time, :completion_time2;

    cout << " GetSwitchSceneDataCursor " << sqlca.sqlcode << endl;

 

此时sqlca.sqlcode的值为-24343. 如果把宿主变量 SQLSTR的定义” char SQLSTR[500];“改为

”char SQLSTR[1000];“ 则此时不会出现ORA-24343错误。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值