现在的位置: 首页 > 综合 > 正文

出现Oracle ORA-24343的一种情况

2013年10月18日 ⁄ 综合 ⁄ 共 1620字 ⁄ 字号 评论关闭

    对于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错误。

 

抱歉!评论已关闭.