execute a command with binding variables execaute SQL which has bind variables, the only data types supported for now are: string, timestamp, integer the number of bind variables in the sql must be the same as the number of strings pointed by val_arr. 1) bnd_cnt should be the number of strings in the array; 2) val_arr is the array of strings; 3) typ_arr is the array of data types for the strings; Implements JobQueueDatabase. Definition at line 1694 of file oracledatabase.cpp. References JobQueueDatabase::connected, disconnectDB(), and MyString::sprintf(). { struct timeval tvStart, tvEnd; int i; oracle::occi::Stream *instream; if (!connected) { dprintf(D_ALWAYS, "Not connected to database in ORACLEDatabase::execCommand\n"); return QUILL_FAILURE; } dprintf(D_FULLDEBUG, "SQL COMMAND: %s\n", sql); #ifdef TT_COLLECT_SQL fprintf(sqllog_fp, "%s;\n", sql); fflush(sqllog_fp); #endif #ifdef TT_TIME_SQL gettimeofday( &tvStart, NULL ); #endif try { stmt = conn->createStatement (sql); for ( i = 1; i <= bnd_cnt; i++) { if (typ_arr[i-1] == CONDOR_TT_TYPE_STRING) { stmt->setString(i, val_arr[i-1]); } else if (typ_arr[i-1] == CONDOR_TT_TYPE_NUMBER) { stmt->setInt(i, *(const int *)val_arr[i-1]); } else if (typ_arr[i-1] == CONDOR_TT_TYPE_TIMESTAMP) { // timestamp oracle::occi::Timestamp ts1; ts1.fromText(val_arr[i-1], QUILL_ORACLE_TIMESTAMP_FORAMT, "", env); stmt->setTimestamp(i, ts1); } else { dprintf(D_ALWAYS, "unknown data type in ORACLEDatabase::execCommandWithBind\n"); conn->terminateStatement (stmt); return QUILL_FAILURE; } } stmt->executeUpdate (); } catch (SQLException ex) { dprintf(D_ALWAYS, "ERROR EXECUTING UPDATE\n"); dprintf(D_ALWAYS, "[SQL: %s]\n", sql); dprintf(D_ALWAYS, "Error number: %d, Error message: %s in ORACLEDatabase::execCommand\n", ex.getErrorCode(), ex.getMessage().c_str()); errorMsg.sprintf("Error number: %d, Error message: %s", ex.getErrorCode(), ex.getMessage().c_str()); conn->terminateStatement (stmt); stmt = NULL; /* ORA-03113 means that the connection between Client and Server process was broken. */ /* ORA-04031 means that shared pool is out of memory. Disconnect so that we avoid getting the same error over and over. Also this will avoid the sql log being truncated. */ if (ex.getErrorCode() == 3113 || ex.getErrorCode() == 3114 || ex.getErrorCode() == 4031) { emailDBError(ex.getErrorCode(), "Oracle"); disconnectDB(); } return QUILL_FAILURE; } conn->terminateStatement (stmt); #ifdef TT_TIME_SQL gettimeofday( &tvEnd, NULL ); dprintf(D_FULLDEBUG, "Execution time: %ld\n", (tvEnd.tv_sec - tvStart.tv_sec)*1000 + (tvEnd.tv_usec - tvStart.tv_usec)/1000); #endif stmt = NULL; return QUILL_SUCCESS; }
|