Re: Use of TSQLServer

From: Fons Rademakers <Fons.Rademakers_at_cern.ch>
Date: Fri, 08 Apr 2005 16:36:38 +0200


Hi Yan Liu,

   notice that the current TOracleRow::GetField() is not correct. GetField() for all RDBMS plugins must return the value in ASCII, not a pointer to a basic type that has to be casted. By not doing that you break the abstract interface and the expected behavior (and besides you are leaking all the new'ed types and strings). If the user want to get integers or floats he will have to use atoi and atof on the returned strings. If we want to extend the interface with what you want to do we should introduce a new method like void *TSQLRow::GetRawField() and provide this for all plugins.

Also try to asap provide GetRowCount() since that is a quite essential method.

Cheers, Fons.

liuyan_at_fnal.gov wrote:

> Hi,
> 

>>int rowNr = res->GetRowCount();
>>
>>I obtain as result -1.
> 
> 
> As Philippe mentioned, we haven't implemented GetRowCount() yet. But I will add a warning message indicating so when user calls this function.
> 
> 

>>if I use row->GetField(0) root crashes without any error message,
>>with row->GetField(1) I get a result that I tried to convert to a string,
>>but I get only strange outputs and with row->GetField(2) I get the message:
>> Error in <TOracleRow::IsValid>: field index out of bounds
> 
> User should call TSQLResult::Next() first to get a pointer to the 1st row, like TSQLRow *row = result_set->Next(). If you have done so, please remember to convert return value of GetField() to proper type. In TSQL specification, TSQLRow::GetField() only returns a (void *) pointer. User needs to cast this pointer by himself. In general, this conversion is like: COLUMN_TYPE col_value = *(COLUMN_TYPE *)row->GetField(0). For example, for integer type, replace "COLUMN_TYPE" with "int" or "UInt_t". For string type, replace "COLUMN_TYPE" with "char *". The column index range is from 0 to GetFieldCount()-1.
> 
> Thanks.
> 
> Yan Liu
> 
> ----- Original Message -----
> From: Philippe Canal <pcanal_at_fnal.gov>
> Date: Thursday, April 7, 2005 12:14 pm
> Subject: RE: [ROOT] Use of TSQLServer
> 
> 

>>Hi,
>>
>>This new oracle plugin is still very much in development.
>>GetRowCount is indeed not yet implemented. The rest should
>>have worked :(. We will look into it as soon as possible.
>>
>>Thanks for reporting this problem.
>>
>>Cheers,
>>Philippe.
>>
>>-----Original Message-----
>>From: owner-roottalk_at_pcroot.cern.ch [owner-roottalk_at_pcroot.cern.ch]
>>On Behalf Of Marina Giunta
>>Sent: Wednesday, April 06, 2005 10:55 AM
>>To: Roottalk
>>Subject: [ROOT] Use of TSQLServer
>>
>>Hello,
>>I am trying to use ROOT with data stored in an Oracle db.
>>
>>I perform a query using:
>>TSQLResult *res=db->Query(SELECT element_id, element_name FROM
>>elements);
>>I know the query returns the right number of rows, because by
>>looping over
>>them I get the right total number,but using:
>>
>>int rowNr = res->GetRowCount();
>>
>>I obtain as result -1.
>>
>>Then, res->GetFieldCount() gives as result 2, but then, if I try to
>>get
>>the contents of the fields using TSQLRow::GetField(Int_t field), if
>>I use
>>row->GetField(0)
>>root crashes without any error message, with
>>row->GetField(1)
>>I get a result that I tried to convert to a string, but I get only
>>strange outputs and with
>>row->GetField(2) I get the message:
>>Error in <TOracleRow::IsValid>: field index out of bounds
>>
>>How do I get the contents of my two fields?
>>
>>Thanks
>> Marina
>>
>>--
>>Marina Giunta
>>-----------------------------------------------
>>Department of Physics, | At CERN
>>UC Riverside, | OFF: 28-2-006
>>Riverside CA92521 USA | TEL: +41-22-76-78178
>>-----------------------------------------------
>>
>>
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers_at_cern.ch              Phone: +41 22 7679248
WWW:    http://www.rademakers.org/fons/      Fax:   +41 22 7679480
Received on Fri Apr 08 2005 - 16:36:46 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:06 MET