Re: [ROOT] A simple help...

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Fri Feb 08 2002 - 11:40:05 MET


Hi Alberto, 

On Fri, 08 Feb 2002 09:26:14 +0100
"Alberto P." <avmap75@inwind.it> wrote
concerning "[ROOT] A simple help...":
> Dear all,
> is there anyone who has used the SQL interface to TTree, and can give me 
> an example about how to use SQL statements with the TTrees?

The short story: You can't.  

The long story: You _must_ use the normal TSelector syntax, that is 

  <variable list>, <selection> 

for example 

  typedef struct Foo { 
     Float_t x, y, z; 
  } Foo_t; 

  Foo foo;

  TTree* tree = new TTree("T", "T"); 
  tree->Branch("foo", &tuple, "x/f:y:z"); 
  ...
  TSQLResult* res = tree->Query("foo.x:foo.y", "foo.x > 100"); 
  TSQLRow*    row = 0;
  while ((row = res->Next())) 
    cout << "Row: " << row->GetEntry(0) << 
         << ", " << row->GetEntry(0) << endl;

It would be nice if one could do 

  TQSLResult* row = tree->Query("SELECT x, y FROM foo WHERE x > 100");

but that requires writing a SQL parser that translates SQL to the
TSelector syntax.  Such an interface would make the access to a ROOT
file, MySQL, PostGreSQL, Oracle, SapDB, etc. access completly
transparant: 

  TSQLServer* server = TSQLServer::Connect(<db>); 
  TQSLResult* row = server->Query("SELECT x, y FROM foo WHERE x > 100");
  
where 

  <db>                      := <backend> :// <host> / <db> 
  <backend>                 := root 
                            |  mysql   
                            |  pgqsl
                            |  oracle 
                            |  sapdb
                            |  ...

  <host>                    := <ip-address or host name>
                            |  <ip-address or host name> : <port>
  <ip-address or host name> := <ip-address>
                            |  <host name>
  

And a transaction based rootd could then effectively make ROOT a real
viable alternative to Objectivity both for buisness and academia. :-) 

Ofcourse, all this takes time and effort to implement, which is not
avaliable in bunches :-( 

Yours, 

Christian Holm Christensen -------------------------------------------
Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
         DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
         Denmark                             Office: (+45) 353  25 305 
Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET