Logo Search packages:      
Sourcecode: condor version File versions  Download package

QuillErrCode ORACLEDatabase::execCommand ( const char *  sql,
int &  num_result 
) [virtual]

execute a command

execaute SQL which doesn't have any retrieved result, such as insert, delete, and udpate.

Implements JobQueueDatabase.

Definition at line 377 of file oracledatabase.cpp.

References JobQueueDatabase::connected, disconnectDB(), and MyString::sprintf().

{
      struct timeval tvStart, tvEnd;

      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);
            num_result = 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;
}


Generated by  Doxygen 1.6.0   Back to index