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

QuillErrCode ORACLEDatabase::execQuery ( const char *  sql,
ResultSet *&  result,
Statement *&  stmt,
int &  num_result 
)

execute a SQL query

Definition at line 452 of file oracledatabase.cpp.

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

{
      ResultSet *res;
      ResultSet::Status rs;
      int temp=0;

      if (!connected) {
            dprintf(D_ALWAYS, "Not connected to database in ORACLEDatabase::execQuery\n");
            num_result = -1;
            return QUILL_FAILURE;
      }

      dprintf(D_FULLDEBUG, "SQL Query = %s\n", sql);

      try {
            stmt = conn->createStatement (sql);
            res = stmt->executeQuery ();
            
                  /* fetch from res to count the number of rows */
            while ((rs = res->next()) != ResultSet::END_OF_FETCH) {
                  temp++;     
            }

            stmt->closeResultSet (res);
            
                  /* query again to get new result structure to pass back */
            result = stmt->executeQuery();
            num_result = temp;      
            
      } catch (SQLException ex) {
            conn->terminateStatement (stmt);
            result = NULL;
            stmt = NULL;
            
            dprintf(D_ALWAYS, "ERROR EXECUTING QUERY\n");
            dprintf(D_ALWAYS,  "[SQL: %s]\n", sql);         
            dprintf(D_ALWAYS, "Error number: %d, Error message: %s in ORACLEDatabase::execQuery\n", ex.getErrorCode(), ex.getMessage().c_str());
            errorMsg.sprintf("Error number: %d, Error message: %s", 
                                    ex.getErrorCode(), ex.getMessage().c_str());
            
                  /* 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();
            }                   

            num_result = -1;

            return QUILL_FAILURE;                 
      }

      return QUILL_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index