Root db connection error

Dear all,

I’am trying to connect to the database using root version 5.32.01 on Windows XP.
I tested the query on the sql development and it is working fine.
But when I try to use it with root, I get a large number of fields and negative and root crash.
The code is below.
Thanks.

#include "TOracleRow.h"
#include "Riostream.h"
#include "TSQLServer.h"
#include "TSQLResult.h"
#include "TSQLRow.h"
#include "TOracleResult.h"
#include "TOracleRow.h"
#include <string.h>
#include <vector.h>

void generic_onedp(){


  ofstream fp1;
  fp1.open("output.txt");

  TSQLServer *db= TSQLServer::Connect("………");  

  if(!db->IsConnected()){
    cout<<"not connected"<<endl;
    db->Close();
    return;
  }

//            printf("Server info: %s\n", db->ServerInfo());
//            cout << "Server info: " << db->ServerInfo() << endl;

                TSQLRow *row;
                TSQLResult *res;
                cout<<"connected to database"<<endl;
  
                string                     systemnamedp="cms_cs_dcs_01:CMS_CS/CANBUS_3/ELMB_4/IR_Sensor_00";
                string                     db_name="CMS_CS_DCS_PVSS_COND";
                string                     start_t="07/09/2011, 00:00:00"; 
                string                     end_t="07/29/2011, 23:59:59";
                string                     sensortype="IR_SENSOR";
                string                     typedata="VALUE";
  cout<<"start_t = "<<start_t<<endl;
  cout<<"end_t = "<<end_t<<endl;
  
  char query[1000];
                
                
sprintf(query, "select to_char(change_date,'mm/dd/yyyy, hh24:mi:ss'), value from CMS_CS_DCS_PVSS_COND.IR_SENSOR, CMS_CS_DCS_PVSS_COND.DP_NAME2ID where IR_SENSOR.DPID = DP_NAME2ID.ID and change_date>=to_date('08/01/2011, 00:00:00','mm/dd/yyyy, hh24:mi:ss') and change_date<=to_date('10/01/2011, 23:59:59','mm/dd/yyyy, hh24:mi:ss') and VALUE is not null and DP_NAME2ID.dpname like 'cms_cs_dcs_01:CMS_CS/CANBUS_3/ELMB_4/IR_Sensor_16' order by change_date asc"); 
                
                cout<<"query: "<<query<<endl;

TSQLResult * res=db->Query(query);
  if(db->IsError()){
    db->Close();
    return; 
  }
  if(res==NULL){
    db->Close();
    return;
  }  
  int fields=0, rows=0;
  fields=res->GetFieldCount();
  rows=res->GetRowCount();
  cout << "rows = " << rows << endl;
  cout << "fields = " << fields << endl;
  for(int rc=0;rc<rows;rc++){
    TSQLRow *row=res->Next(); 
    cout<<row->GetField(0)<<" "<<row->GetField(1)<<endl;
    fp1<<row->GetField(0)<<" "<<row->GetField(1)<<endl;
                delete row;
  } 

  delete res;
  db->Close();
  fp1.close();
                
                }

Many thanks.


I didn’t yet had found a solution for the problem…
I had tried even with a more compact query but the problem had remained.

Cheers,

Antunes

I tried your macro. I get:

Processing generic_onedp.C...
Error: cannot open file "TOracleRow.h"  generic_onedp.C:2:
*** Interpreter error recovered ***

I have never used this Oracle interface in ROOT so I am not really of a great help.
I can suggest some ideas:

  • have you tried on an other machine than Windows ?
  • have you tried to run you macro using AClic ?

Have you tried with a minimal query such as “select(*) from <1table>” and see if it works ?
If it works, then build up the query bit by bit, testing each time, until you find what is wrong, either in your code or in ROOT.

Cheers
Barth