TPgSQLStatement.cxx

Go to the documentation of this file.
00001 // @(#)root/pgsql:$Id: TPgSQLStatement.cxx 35527 2010-09-21 12:27:01Z brun $
00002 // Author: Dennis Box (dbox@fnal.gov)  3/12/2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 //  SQL statement class for PgSQL                                       //
00015 //                                                                      //
00016 //  See TSQLStatement class documentation for more details.             //
00017 //                                                                      //
00018 //////////////////////////////////////////////////////////////////////////
00019 
00020 #include "TPgSQLStatement.h"
00021 #include "TDataType.h"
00022 #include "TDatime.h"
00023 
00024 #include <stdlib.h>
00025 
00026 ClassImp(TPgSQLStatement)
00027 
00028 #ifdef PG_VERSION_NUM
00029 
00030 //______________________________________________________________________________
00031 TPgSQLStatement::TPgSQLStatement(PgSQL_Stmt_t* stmt, Bool_t errout):
00032    TSQLStatement(errout),
00033    fStmt(stmt),
00034    fNumBuffers(0),
00035    fBind(0),
00036    fFieldName(0),
00037    fWorkingMode(0),
00038    fIterationCount(0),
00039    fParamLengths(0),
00040    fParamFormats(0),
00041    fNumResultRows(0),
00042    fNumResultCols(0)
00043 {
00044    // Normal constructor.
00045    // Checks if statement contains parameters tags.
00046 
00047    fStmt->fRes = PQdescribePrepared(fStmt->fConn,"");
00048    unsigned long paramcount = PQnparams(fStmt->fRes);
00049    fNumResultCols = PQnfields(fStmt->fRes);
00050    fIterationCount = -1;
00051 
00052    if (paramcount>0) {
00053       fWorkingMode = 1;
00054       SetBuffersNumber(paramcount);
00055    } else {
00056       fWorkingMode = 2;
00057       SetBuffersNumber(fNumResultCols);
00058    }
00059 }
00060 
00061 //______________________________________________________________________________
00062 TPgSQLStatement::~TPgSQLStatement()
00063 {
00064    // Destructor.
00065 
00066    Close();
00067 }
00068 
00069 //______________________________________________________________________________
00070 void TPgSQLStatement::Close(Option_t *)
00071 {
00072    // Close statement.
00073 
00074    if (fStmt->fRes)
00075       PQclear(fStmt->fRes);
00076 
00077    fStmt->fRes = 0;
00078 
00079    FreeBuffers();
00080    //TPgSQLServers responsibility to free connection
00081    fStmt->fConn=0;
00082    delete fStmt;
00083 }
00084 
00085 
00086 // Reset error and check that statement exists
00087 #define CheckStmt(method, res)                          \
00088    {                                                    \
00089       ClearError();                                     \
00090       if (fStmt==0) {                                   \
00091          SetError(-1,"Statement handle is 0",method);   \
00092          return res;                                    \
00093       }                                                 \
00094    }
00095 
00096 #define CheckErrNo(method, force, wtf)                  \
00097    {                                                    \
00098       int stmterrno = PQresultStatus(fStmt->fRes);      \
00099       if ((stmterrno!=0) || force) {                        \
00100          const char* stmterrmsg = PQresultErrorMessage(fStmt->fRes);  \
00101          if (stmterrno==0) { stmterrno = -1; stmterrmsg = "PgSQL statement error"; } \
00102          SetError(stmterrno, stmterrmsg, method);               \
00103          return wtf;                                    \
00104       }                                                 \
00105    }
00106 
00107 // check last pgsql statement error code
00108 #define CheckGetField(method, res)                      \
00109    {                                                    \
00110       ClearError();                                     \
00111       if (!IsResultSetMode()) {                         \
00112          SetError(-1,"Cannot get statement parameters",method); \
00113          return res;                                    \
00114       }                                                 \
00115       if ((npar<0) || (npar>=fNumBuffers)) {            \
00116          SetError(-1,Form("Invalid parameter number %d", npar),method); \
00117          return res;                                    \
00118       }                                                 \
00119    }
00120 
00121 //________________________________________________________________________
00122 Bool_t TPgSQLStatement::Process()
00123 {
00124    // Process statement.
00125 
00126    CheckStmt("Process",kFALSE);
00127 
00128    if (IsSetParsMode()) {
00129       fStmt->fRes= PQexecPrepared(fStmt->fConn,"",fNumBuffers,
00130                                  (const char* const*)fBind,
00131                                  0,0,0);
00132 
00133    } else { //result set mode
00134 
00135       fStmt->fRes= PQexecPrepared(fStmt->fConn,"",0,(const char* const*) 0,0,0,0);
00136    }
00137    ExecStatusType stat = PQresultStatus(fStmt->fRes);
00138    if (!pgsql_success(stat))
00139       CheckErrNo("Process",kTRUE, kFALSE);
00140    return kTRUE;
00141 }
00142 
00143 //________________________________________________________________________
00144 Int_t TPgSQLStatement::GetNumAffectedRows()
00145 {
00146    // Return number of affected rows after statement is processed.
00147 
00148    CheckStmt("GetNumAffectedRows", -1);
00149 
00150    return (Int_t) atoi(PQcmdTuples(fStmt->fRes));
00151 }
00152 
00153 //______________________________________________________________________________
00154 Int_t TPgSQLStatement::GetNumParameters()
00155 {
00156    // Return number of statement parameters.
00157 
00158    CheckStmt("GetNumParameters", -1);
00159 
00160    Int_t res = PQnparams(fStmt->fRes);
00161 
00162    CheckErrNo("GetNumParameters", kFALSE, -1);
00163 
00164    return res;
00165 }
00166 
00167 //______________________________________________________________________________
00168 Bool_t TPgSQLStatement::StoreResult()
00169 {
00170    // Store result of statement processing to access them
00171    // via GetInt(), GetDouble() and so on methods.
00172 
00173    int i;
00174    for (i=0;i<fNumResultCols;i++){
00175       fFieldName[i] = PQfname(fStmt->fRes,i);
00176       fParamFormats[i]=PQftype(fStmt->fRes,i);
00177       fParamLengths[i]=PQfsize(fStmt->fRes,i);
00178 
00179    }
00180    fNumResultRows=PQntuples(fStmt->fRes);
00181    ExecStatusType stat = PQresultStatus(fStmt->fRes);
00182    fWorkingMode = 2;
00183    if (!pgsql_success(stat))
00184       CheckErrNo("StoreResult",kTRUE, kFALSE);
00185    return kTRUE;
00186 }
00187 
00188 //______________________________________________________________________________
00189 Int_t TPgSQLStatement::GetNumFields()
00190 {
00191    // Return number of fields in result set.
00192 
00193    if (fWorkingMode==1)
00194       return fNumBuffers;
00195    if (fWorkingMode==2)
00196       return fNumResultCols;
00197    return -1;
00198 }
00199 
00200 //______________________________________________________________________________
00201 const char* TPgSQLStatement::GetFieldName(Int_t nfield)
00202 {
00203    // Returns field name in result set.
00204 
00205    if (!IsResultSetMode() || (nfield<0) || (nfield>=fNumBuffers)) return 0;
00206 
00207    return fFieldName[nfield];
00208 }
00209 
00210 //______________________________________________________________________________
00211 Bool_t TPgSQLStatement::NextResultRow()
00212 {
00213    // Shift cursor to nect row in result set.
00214 
00215    if ((fStmt==0) || !IsResultSetMode()) return kFALSE;
00216 
00217    Bool_t res=kTRUE;
00218 
00219    fIterationCount++;
00220    if (fIterationCount>=fNumResultRows)
00221      res=kFALSE;
00222    return res;
00223 }
00224 
00225 //______________________________________________________________________________
00226 Bool_t TPgSQLStatement::NextIteration()
00227 {
00228    // Increment iteration counter for statement, where parameter can be set.
00229    // Statement with parameters of previous iteration
00230    // automatically will be applied to database.
00231 
00232    ClearError();
00233 
00234    if (!IsSetParsMode() || (fBind==0)) {
00235       SetError(-1,"Cannot call for that statement","NextIteration");
00236       return kFALSE;
00237    }
00238 
00239    fIterationCount++;
00240 
00241    if (fIterationCount==0) return kTRUE;
00242 
00243    fStmt->fRes= PQexecPrepared(fStmt->fConn,"",fNumBuffers,
00244                                (const char* const*)fBind,
00245                                0,//fParamLengths,
00246                                0,//fParamFormats,
00247                                0);
00248    ExecStatusType stat = PQresultStatus(fStmt->fRes);
00249    if (!pgsql_success(stat) ){
00250       CheckErrNo("NextIteration", kTRUE, kFALSE) ;
00251       return kFALSE;
00252    }
00253    return kTRUE;
00254 }
00255 
00256 //______________________________________________________________________________
00257 void TPgSQLStatement::FreeBuffers()
00258 {
00259    // Release all buffers, used by statement.
00260 
00261   //individual field names free()'ed by PQClear of fStmt->fRes
00262    if (fFieldName)
00263       delete[] fFieldName;
00264 
00265    if (fBind){
00266       for (Int_t i=0;i<fNumBuffers;i++)
00267          delete [] fBind[i];
00268       delete[] fBind;
00269    }
00270 
00271    if (fParamLengths)
00272       delete [] fParamLengths;
00273 
00274    if (fParamFormats)
00275       delete [] fParamFormats;
00276 
00277    fFieldName = 0;
00278    fBind = 0;
00279    fNumBuffers = 0;
00280    fParamLengths = 0;
00281    fParamFormats = 0;
00282 }
00283 
00284 //______________________________________________________________________________
00285 void TPgSQLStatement::SetBuffersNumber(Int_t numpars)
00286 {
00287    // Allocate buffers for statement parameters/ result fields.
00288 
00289    FreeBuffers();
00290    if (numpars<=0) return;
00291 
00292    fNumBuffers = numpars;
00293 
00294    fBind = new char*[fNumBuffers];
00295    for(int i=0; i<fNumBuffers; ++i){
00296       fBind[i]=new char[25]; //big enough to handle text rep. of 64 bit number
00297    }
00298    fFieldName = new char*[fNumBuffers];
00299 
00300    fParamLengths = new int[fNumBuffers];
00301    memset(fParamLengths, 0, sizeof(int)*fNumBuffers);
00302 
00303    fParamFormats = new int[fNumBuffers];
00304    memset(fParamFormats, 0, sizeof(int)*fNumBuffers);
00305 }
00306 
00307 //______________________________________________________________________________
00308 const char* TPgSQLStatement::ConvertToString(Int_t npar)
00309 {
00310    // Convert field value to string.
00311 
00312    const char *buf = PQgetvalue(fStmt->fRes, fIterationCount, npar);
00313    return buf;
00314 }
00315 
00316 //______________________________________________________________________________
00317 long double TPgSQLStatement::ConvertToNumeric(Int_t npar)
00318 {
00319    // Convert field to numeric.
00320 
00321    if (PQgetisnull(fStmt->fRes,fIterationCount,npar))
00322       return (long double)0;
00323 
00324    return (long double) atof(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00325 }
00326 
00327 //______________________________________________________________________________
00328 Bool_t TPgSQLStatement::IsNull(Int_t npar)
00329 {
00330    // Checks if field value is null.
00331 
00332    CheckGetField("IsNull", kTRUE);
00333 
00334    return PQgetisnull(fStmt->fRes,fIterationCount,npar);
00335 }
00336 
00337 //______________________________________________________________________________
00338 Int_t TPgSQLStatement::GetInt(Int_t npar)
00339 {
00340    // Get integer.
00341 
00342    if (PQgetisnull(fStmt->fRes,fIterationCount,npar))
00343       return (Int_t)0;
00344 
00345    return (Int_t) atoi(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00346 }
00347 
00348 //______________________________________________________________________________
00349 UInt_t TPgSQLStatement::GetUInt(Int_t npar)
00350 {
00351    // Get unsigned integer.
00352 
00353    if (PQgetisnull(fStmt->fRes,fIterationCount,npar))
00354       return (UInt_t)0;
00355 
00356    return (UInt_t) atoi(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00357 }
00358 
00359 //______________________________________________________________________________
00360 Long_t TPgSQLStatement::GetLong(Int_t npar)
00361 {
00362    // Get long.
00363 
00364    if (PQgetisnull(fStmt->fRes,fIterationCount,npar))
00365       return (Long_t)0;
00366 
00367    return (Long_t) atol(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00368 }
00369 
00370 //______________________________________________________________________________
00371 Long64_t TPgSQLStatement::GetLong64(Int_t npar)
00372 {
00373    // Get long64.
00374 
00375    if (PQgetisnull(fStmt->fRes,fIterationCount,npar))
00376       return (Long64_t)0;
00377 
00378 #ifndef R__WIN32
00379    return (Long64_t) atoll(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00380 #else
00381    return (Long64_t) _atoi64(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00382 #endif
00383 }
00384 
00385 //______________________________________________________________________________
00386 ULong64_t TPgSQLStatement::GetULong64(Int_t npar)
00387 {
00388    // Return field value as unsigned 64-bit integer
00389 
00390    if (PQgetisnull(fStmt->fRes,fIterationCount,npar))
00391       return (ULong64_t)0;
00392 
00393 #ifndef R__WIN32
00394    return (ULong64_t) atoll(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00395 #else
00396    return (ULong64_t) _atoi64(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00397 #endif
00398 }
00399 
00400 //______________________________________________________________________________
00401 Double_t TPgSQLStatement::GetDouble(Int_t npar)
00402 {
00403    // Return field value as double.
00404 
00405    if (PQgetisnull(fStmt->fRes,fIterationCount,npar))
00406       return (Double_t)0;
00407    return (Double_t) atof(PQgetvalue(fStmt->fRes,fIterationCount,npar));
00408 }
00409 
00410 //______________________________________________________________________________
00411 const char *TPgSQLStatement::GetString(Int_t npar)
00412 {
00413    // Return field value as string.
00414 
00415    return PQgetvalue(fStmt->fRes,fIterationCount,npar);
00416 }
00417 
00418 //______________________________________________________________________________
00419 Bool_t TPgSQLStatement::GetBinary(Int_t npar, void* &mem, Long_t& size)
00420 {
00421    // Return field value as binary array.
00422    // Note PQgetvalue mallocs/frees and ROOT classes expect new/delete.
00423 
00424    size_t sz;
00425    char *cptr = PQgetvalue(fStmt->fRes,fIterationCount,npar);
00426    unsigned char * mptr = PQunescapeBytea((const unsigned char*)cptr,&sz);
00427    if ((Long_t)sz>size) {
00428       delete [] (unsigned char*) mem;
00429       mem = (void*) new unsigned char[sz];
00430    }
00431    size=sz;
00432    memcpy(mem,mptr,sz);
00433    PQfreemem(mptr);
00434    return kTRUE;
00435 }
00436 
00437 //______________________________________________________________________________
00438 Bool_t TPgSQLStatement::GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day)
00439 {
00440    // Return field value as date.
00441 
00442    TString val=PQgetvalue(fStmt->fRes,fIterationCount,npar);
00443    TDatime d = TDatime(val.Data());
00444    year = d.GetYear();
00445    month = d.GetMonth();
00446    day= d.GetDay();
00447    return kTRUE;
00448 }
00449 
00450 //______________________________________________________________________________
00451 Bool_t TPgSQLStatement::GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec)
00452 {
00453    // Return field as time.
00454 
00455    TString val=PQgetvalue(fStmt->fRes,fIterationCount,npar);
00456    TDatime d = TDatime(val.Data());
00457    hour = d.GetHour();
00458    min = d.GetMinute();
00459    sec= d.GetSecond();
00460    return kTRUE;
00461 }
00462 
00463 //______________________________________________________________________________
00464 Bool_t TPgSQLStatement::GetDatime(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec)
00465 {
00466    // Return field value as date & time.
00467 
00468    TString val=PQgetvalue(fStmt->fRes,fIterationCount,npar);
00469    TDatime d = TDatime(val.Data());
00470    year = d.GetYear();
00471    month = d.GetMonth();
00472    day= d.GetDay();
00473    hour = d.GetHour();
00474    min = d.GetMinute();
00475    sec= d.GetSecond();
00476    return kTRUE;
00477 }
00478 
00479 //______________________________________________________________________________
00480 Bool_t TPgSQLStatement::GetTimestamp(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec, Int_t& frac)
00481 {
00482    // Return field as timestamp.
00483 
00484    TString val=PQgetvalue(fStmt->fRes,fIterationCount,npar);
00485    Ssiz_t p = val.Last('.');
00486    TSubString s_frac = val(p,val.Length()-p+1);
00487    TDatime d = TDatime(val.Data());
00488    year = d.GetYear();
00489    month = d.GetMonth();
00490    day= d.GetDay();
00491    hour = d.GetHour();
00492    min = d.GetMinute();
00493    sec= d.GetSecond();
00494    frac=atoi(s_frac.Data());
00495    return kTRUE;
00496 }
00497 
00498 //______________________________________________________________________________
00499 Bool_t TPgSQLStatement::SetNull(Int_t npar)
00500 {
00501    // Set NULL as parameter value.
00502    // If NULL should be set for statement parameter during first iteration,
00503    // one should call before proper Set... method to identify type of argument for
00504    // the future. For instance, if one suppose to have double as type of parameter,
00505    // code should look like:
00506    //    stmt->SetDouble(2, 0.);
00507    //    stmt->SetNull(2);
00508 
00509    fBind[npar][0] = 0;
00510 
00511    return kTRUE;
00512 }
00513 
00514 //______________________________________________________________________________
00515 Bool_t TPgSQLStatement::SetInt(Int_t npar, Int_t value)
00516 {
00517    // Set parameter value as integer.
00518 
00519    sprintf(fBind[npar],"%d",value);
00520 
00521    return kTRUE;
00522 }
00523 
00524 //______________________________________________________________________________
00525 Bool_t TPgSQLStatement::SetUInt(Int_t npar, UInt_t value)
00526 {
00527    // Set parameter value as unsinged integer.
00528 
00529    sprintf(fBind[npar],"%u",value);
00530 
00531    return kTRUE;
00532 }
00533 
00534 //______________________________________________________________________________
00535 Bool_t TPgSQLStatement::SetLong(Int_t npar, Long_t value)
00536 {
00537    // Set parameter value as long.
00538 
00539    sprintf(fBind[npar],"%ld",value);
00540 
00541    return kTRUE;
00542 }
00543 
00544 //______________________________________________________________________________
00545 Bool_t TPgSQLStatement::SetLong64(Int_t npar, Long64_t value)
00546 {
00547    // Set parameter value as 64-bit integer.
00548 
00549    sprintf(fBind[npar],"%lld",(Long64_t)value);
00550 
00551    return kTRUE;
00552 }
00553 
00554 //______________________________________________________________________________
00555 Bool_t TPgSQLStatement::SetULong64(Int_t npar, ULong64_t value)
00556 {
00557    // Set parameter value as unsinged 64-bit integer.
00558 
00559    sprintf(fBind[npar],"%llu",(ULong64_t)value);
00560 
00561    return kTRUE;
00562 }
00563 
00564 //______________________________________________________________________________
00565 Bool_t TPgSQLStatement::SetDouble(Int_t npar, Double_t value)
00566 {
00567    // Set parameter value as double value.
00568 
00569    sprintf(fBind[npar],"%lf",value);
00570 
00571    return kTRUE;
00572 }
00573 
00574 //______________________________________________________________________________
00575 Bool_t TPgSQLStatement::SetString(Int_t npar, const char* value, Int_t maxsize)
00576 {
00577    // Set parameter value as string.
00578 
00579    if(sizeof(fBind[npar])<(unsigned)maxsize){
00580       delete [] fBind[npar];
00581       fBind[npar] = new char[maxsize];
00582    }
00583    strlcpy(fBind[npar],value,maxsize);
00584    return kTRUE;
00585 }
00586 
00587 //______________________________________________________________________________
00588 Bool_t TPgSQLStatement::SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize)
00589 {
00590    // Set parameter value as binary data.
00591 
00592    size_t sz=size;
00593    size_t mxsz=maxsize;
00594    char* mptr = (char*)malloc(2*sz+1);
00595    mxsz=PQescapeString (mptr,(char*)mem,sz);
00596 
00597    delete [] fBind[npar];
00598    fBind[npar]= new char[mxsz+1];
00599    memcpy(fBind[npar],mptr,mxsz);
00600    free(mptr);
00601    return kTRUE;
00602 }
00603 
00604 //______________________________________________________________________________
00605 Bool_t TPgSQLStatement::SetDate(Int_t npar, Int_t year, Int_t month, Int_t day)
00606 {
00607    // Set parameter value as date.
00608 
00609    TDatime d =TDatime(year,month,day,0,0,0);
00610    sprintf(fBind[npar],"%s",(char*)d.AsSQLString());
00611 
00612    return kFALSE;
00613 }
00614 
00615 //______________________________________________________________________________
00616 Bool_t TPgSQLStatement::SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec)
00617 {
00618    // Set parameter value as time.
00619 
00620    TDatime d=TDatime(2000,1,1,hour,min,sec);
00621    sprintf(fBind[npar],"%s",(char*)d.AsSQLString());
00622    return kTRUE;
00623 }
00624 
00625 //______________________________________________________________________________
00626 Bool_t TPgSQLStatement::SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec)
00627 {
00628    // Set parameter value as date & time.
00629 
00630    TDatime d=TDatime(year,month,day,hour,min,sec);
00631    sprintf(fBind[npar],"%s",(char*)d.AsSQLString());
00632    return kTRUE;
00633 }
00634 
00635 //______________________________________________________________________________
00636 Bool_t TPgSQLStatement::SetTimestamp(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t)
00637 {
00638    // Set parameter value as timestamp.
00639 
00640    TDatime d(year,month,day,hour,min,sec);
00641    sprintf(fBind[npar],"%s",(char*)d.AsSQLString());
00642    return kTRUE;
00643 }
00644 
00645 #else
00646 
00647 //______________________________________________________________________________
00648 TPgSQLStatement::TPgSQLStatement(PgSQL_Stmt_t*, Bool_t)
00649 {
00650    // Normal constructor.
00651    // For PgSQL version < 8.2 no statement is supported.
00652 }
00653 
00654 //______________________________________________________________________________
00655 TPgSQLStatement::~TPgSQLStatement()
00656 {
00657    // Destructor.
00658 }
00659 
00660 //______________________________________________________________________________
00661 void TPgSQLStatement::Close(Option_t *)
00662 {
00663    // Close statement.
00664 }
00665 
00666 //______________________________________________________________________________
00667 Bool_t TPgSQLStatement::Process()
00668 {
00669    // Process statement.
00670 
00671    return kFALSE;
00672 }
00673 
00674 //______________________________________________________________________________
00675 Int_t TPgSQLStatement::GetNumAffectedRows()
00676 {
00677    // Return number of affected rows after statement is processed.
00678 
00679    return 0;
00680 }
00681 
00682 //______________________________________________________________________________
00683 Int_t TPgSQLStatement::GetNumParameters()
00684 {
00685    // Return number of statement parameters.
00686 
00687    return 0;
00688 }
00689 
00690 //______________________________________________________________________________
00691 Bool_t TPgSQLStatement::StoreResult()
00692 {
00693    // Store result of statement processing to access them
00694    // via GetInt(), GetDouble() and so on methods.
00695 
00696    return kFALSE;
00697 }
00698 
00699 //______________________________________________________________________________
00700 Int_t TPgSQLStatement::GetNumFields()
00701 {
00702    // Return number of fields in result set.
00703 
00704    return 0;
00705 }
00706 
00707 //______________________________________________________________________________
00708 const char* TPgSQLStatement::GetFieldName(Int_t)
00709 {
00710    // Returns field name in result set.
00711 
00712    return 0;
00713 }
00714 
00715 //______________________________________________________________________________
00716 Bool_t TPgSQLStatement::NextResultRow()
00717 {
00718    // Shift cursor to nect row in result set.
00719 
00720    return kFALSE;
00721 }
00722 
00723 
00724 //______________________________________________________________________________
00725 Bool_t TPgSQLStatement::NextIteration()
00726 {
00727    // Increment iteration counter for statement, where parameter can be set.
00728    // Statement with parameters of previous iteration
00729    // automatically will be applied to database.
00730 
00731    return kFALSE;
00732 }
00733 
00734 //______________________________________________________________________________
00735 void TPgSQLStatement::FreeBuffers()
00736 {
00737    // Release all buffers, used by statement.
00738 }
00739 
00740 //______________________________________________________________________________
00741 void TPgSQLStatement::SetBuffersNumber(Int_t)
00742 {
00743    // Allocate buffers for statement parameters/ result fields.
00744 }
00745 
00746 //______________________________________________________________________________
00747 const char* TPgSQLStatement::ConvertToString(Int_t)
00748 {
00749    // Convert field value to string.
00750 
00751    return 0;
00752 }
00753 
00754 //______________________________________________________________________________
00755 long double TPgSQLStatement::ConvertToNumeric(Int_t)
00756 {
00757    // Convert field to numeric value.
00758 
00759    return 0;
00760 }
00761 
00762 //______________________________________________________________________________
00763 Bool_t TPgSQLStatement::IsNull(Int_t)
00764 {
00765    // Checks if field value is null.
00766 
00767    return kTRUE;
00768 }
00769 
00770 //______________________________________________________________________________
00771 Int_t TPgSQLStatement::GetInt(Int_t)
00772 {
00773    // Return field value as integer.
00774 
00775    return 0;
00776 }
00777 
00778 //______________________________________________________________________________
00779 UInt_t TPgSQLStatement::GetUInt(Int_t)
00780 {
00781    // Return field value as unsigned integer.
00782 
00783    return 0;
00784 }
00785 
00786 //______________________________________________________________________________
00787 Long_t TPgSQLStatement::GetLong(Int_t)
00788 {
00789    // Return field value as long integer.
00790 
00791    return 0;
00792 }
00793 
00794 //______________________________________________________________________________
00795 Long64_t TPgSQLStatement::GetLong64(Int_t)
00796 {
00797    // Return field value as 64-bit integer.
00798 
00799    return 0;
00800 }
00801 
00802 //______________________________________________________________________________
00803 ULong64_t TPgSQLStatement::GetULong64(Int_t)
00804 {
00805    // Return field value as unsigned 64-bit integer.
00806 
00807    return 0;
00808 }
00809 
00810 //______________________________________________________________________________
00811 Double_t TPgSQLStatement::GetDouble(Int_t)
00812 {
00813    // Return field value as double.
00814 
00815    return 0.;
00816 }
00817 
00818 //______________________________________________________________________________
00819 const char *TPgSQLStatement::GetString(Int_t)
00820 {
00821    // Return field value as string.
00822 
00823    return 0;
00824 }
00825 
00826 //______________________________________________________________________________
00827 Bool_t TPgSQLStatement::GetBinary(Int_t, void* &, Long_t&)
00828 {
00829    // Return field value as binary array.
00830 
00831    return kFALSE;
00832 }
00833 
00834 
00835 //______________________________________________________________________________
00836 Bool_t TPgSQLStatement::GetDate(Int_t, Int_t&, Int_t&, Int_t&)
00837 {
00838    // Return field value as date.
00839 
00840    return kFALSE;
00841 }
00842 
00843 //______________________________________________________________________________
00844 Bool_t TPgSQLStatement::GetTime(Int_t, Int_t&, Int_t&, Int_t&)
00845 {
00846    // Return field value as time.
00847 
00848    return kFALSE;
00849 }
00850 
00851 //______________________________________________________________________________
00852 Bool_t TPgSQLStatement::GetDatime(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&)
00853 {
00854    // Return field value as date & time.
00855 
00856    return kFALSE;
00857 }
00858 
00859 //______________________________________________________________________________
00860 Bool_t TPgSQLStatement::GetTimestamp(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&)
00861 {
00862    // Return field value as time stamp.
00863 
00864    return kFALSE;
00865 }
00866 
00867 //______________________________________________________________________________
00868 Bool_t TPgSQLStatement::SetSQLParamType(Int_t, int, bool, int)
00869 {
00870    // Set parameter type to be used as buffer.
00871    // Used in both setting data to database and retriving data from data base.
00872    // Initialize proper PGSQL_BIND structure and allocate required buffers.
00873 
00874    return kFALSE;
00875 }
00876 
00877 //______________________________________________________________________________
00878 Bool_t TPgSQLStatement::SetNull(Int_t)
00879 {
00880    // Set NULL as parameter value.
00881    // If NULL should be set for statement parameter during first iteration,
00882    // one should call before proper Set... method to identify type of argument for
00883    // the future. For instance, if one suppose to have double as type of parameter,
00884    // code should look like:
00885    //    stmt->SetDouble(2, 0.);
00886    //    stmt->SetNull(2);
00887 
00888    return kFALSE;
00889 }
00890 
00891 //______________________________________________________________________________
00892 Bool_t TPgSQLStatement::SetInt(Int_t, Int_t)
00893 {
00894    // Set parameter value as integer.
00895 
00896    return kFALSE;
00897 }
00898 
00899 //______________________________________________________________________________
00900 Bool_t TPgSQLStatement::SetUInt(Int_t, UInt_t)
00901 {
00902    // Set parameter value as unsigned integer.
00903 
00904    return kFALSE;
00905 }
00906 
00907 //______________________________________________________________________________
00908 Bool_t TPgSQLStatement::SetLong(Int_t, Long_t)
00909 {
00910    // Set parameter value as long integer.
00911 
00912    return kFALSE;
00913 }
00914 
00915 //______________________________________________________________________________
00916 Bool_t TPgSQLStatement::SetLong64(Int_t, Long64_t)
00917 {
00918    // Set parameter value as 64-bit integer.
00919 
00920    return kFALSE;
00921 }
00922 
00923 //______________________________________________________________________________
00924 Bool_t TPgSQLStatement::SetULong64(Int_t, ULong64_t)
00925 {
00926    // Set parameter value as unsigned 64-bit integer.
00927 
00928    return kFALSE;
00929 }
00930 
00931 //______________________________________________________________________________
00932 Bool_t TPgSQLStatement::SetDouble(Int_t, Double_t)
00933 {
00934    // Set parameter value as double.
00935 
00936    return kFALSE;
00937 }
00938 
00939 //______________________________________________________________________________
00940 Bool_t TPgSQLStatement::SetString(Int_t, const char*, Int_t)
00941 {
00942    // Set parameter value as string.
00943 
00944    return kFALSE;
00945 }
00946 
00947 //______________________________________________________________________________
00948 Bool_t TPgSQLStatement::SetBinary(Int_t, void*, Long_t, Long_t)
00949 {
00950    // Set parameter value as binary data.
00951 
00952    return kFALSE;
00953 }
00954 
00955 //______________________________________________________________________________
00956 Bool_t TPgSQLStatement::SetDate(Int_t, Int_t, Int_t, Int_t)
00957 {
00958    // Set parameter value as date.
00959 
00960    return kFALSE;
00961 }
00962 
00963 //______________________________________________________________________________
00964 Bool_t TPgSQLStatement::SetTime(Int_t, Int_t, Int_t, Int_t)
00965 {
00966    // Set parameter value as time.
00967 
00968    return kFALSE;
00969 }
00970 
00971 //______________________________________________________________________________
00972 Bool_t TPgSQLStatement::SetDatime(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
00973 {
00974    // Set parameter value as date & time.
00975 
00976    return kFALSE;
00977 }
00978 
00979 //______________________________________________________________________________
00980 Bool_t TPgSQLStatement::SetTimestamp(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
00981 {
00982    // Set parameter value as timestamp.
00983 
00984    return kFALSE;
00985 }
00986 
00987 #endif  //PG_VERSION_NUM

Generated on Tue Jul 5 15:14:39 2011 for ROOT_528-00b_version by  doxygen 1.5.1