ROOT logo
// @(#)root/pgsql:$Id$
// Author: g.p.ciceri <gp.ciceri@acm.org> 01/06/2001

/*************************************************************************
 * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TPgSQLRow.h"


ClassImp(TPgSQLRow)

//______________________________________________________________________________
TPgSQLRow::TPgSQLRow(void *res, ULong_t rowHandle)
{
   // Single row of query result.

   fResult = (PGresult *) res;
   fRowNum = (ULong_t) rowHandle;
}

//______________________________________________________________________________
TPgSQLRow::~TPgSQLRow()
{
   // Destroy row object.

   if (fRowNum)
      Close();
}

//______________________________________________________________________________
void TPgSQLRow::Close(Option_t *)
{
   // Close row.

   if (!fRowNum)
      return;

   fResult = 0;
   fRowNum = 0;
}

//______________________________________________________________________________
Bool_t TPgSQLRow::IsValid(Int_t field)
{
   // Check if row is open and field index within range.

   if (field < 0 || field >= (Int_t)PQnfields(fResult)) {
      Error("IsValid", "field index out of bounds");
      return kFALSE;
   }
   return kTRUE;
}

//______________________________________________________________________________
ULong_t TPgSQLRow::GetFieldLength(Int_t field)
{
   // Get length in bytes of specified field.

   if (!IsValid(field))
      return 0;

   ULong_t fieldLength = (ULong_t) PQfsize(fResult, field);

   if (!fieldLength) {
      Error("GetFieldLength", "cannot get field length");
      return 0;
   }

   return fieldLength;
}

//______________________________________________________________________________
const char *TPgSQLRow::GetField(Int_t field)
{
   // Get specified field from row (0 <= field < GetFieldCount()).

   if (!IsValid(field))
      return 0;

   return PQgetvalue(fResult, fRowNum, field);
}
 TPgSQLRow.cxx:1
 TPgSQLRow.cxx:2
 TPgSQLRow.cxx:3
 TPgSQLRow.cxx:4
 TPgSQLRow.cxx:5
 TPgSQLRow.cxx:6
 TPgSQLRow.cxx:7
 TPgSQLRow.cxx:8
 TPgSQLRow.cxx:9
 TPgSQLRow.cxx:10
 TPgSQLRow.cxx:11
 TPgSQLRow.cxx:12
 TPgSQLRow.cxx:13
 TPgSQLRow.cxx:14
 TPgSQLRow.cxx:15
 TPgSQLRow.cxx:16
 TPgSQLRow.cxx:17
 TPgSQLRow.cxx:18
 TPgSQLRow.cxx:19
 TPgSQLRow.cxx:20
 TPgSQLRow.cxx:21
 TPgSQLRow.cxx:22
 TPgSQLRow.cxx:23
 TPgSQLRow.cxx:24
 TPgSQLRow.cxx:25
 TPgSQLRow.cxx:26
 TPgSQLRow.cxx:27
 TPgSQLRow.cxx:28
 TPgSQLRow.cxx:29
 TPgSQLRow.cxx:30
 TPgSQLRow.cxx:31
 TPgSQLRow.cxx:32
 TPgSQLRow.cxx:33
 TPgSQLRow.cxx:34
 TPgSQLRow.cxx:35
 TPgSQLRow.cxx:36
 TPgSQLRow.cxx:37
 TPgSQLRow.cxx:38
 TPgSQLRow.cxx:39
 TPgSQLRow.cxx:40
 TPgSQLRow.cxx:41
 TPgSQLRow.cxx:42
 TPgSQLRow.cxx:43
 TPgSQLRow.cxx:44
 TPgSQLRow.cxx:45
 TPgSQLRow.cxx:46
 TPgSQLRow.cxx:47
 TPgSQLRow.cxx:48
 TPgSQLRow.cxx:49
 TPgSQLRow.cxx:50
 TPgSQLRow.cxx:51
 TPgSQLRow.cxx:52
 TPgSQLRow.cxx:53
 TPgSQLRow.cxx:54
 TPgSQLRow.cxx:55
 TPgSQLRow.cxx:56
 TPgSQLRow.cxx:57
 TPgSQLRow.cxx:58
 TPgSQLRow.cxx:59
 TPgSQLRow.cxx:60
 TPgSQLRow.cxx:61
 TPgSQLRow.cxx:62
 TPgSQLRow.cxx:63
 TPgSQLRow.cxx:64
 TPgSQLRow.cxx:65
 TPgSQLRow.cxx:66
 TPgSQLRow.cxx:67
 TPgSQLRow.cxx:68
 TPgSQLRow.cxx:69
 TPgSQLRow.cxx:70
 TPgSQLRow.cxx:71
 TPgSQLRow.cxx:72
 TPgSQLRow.cxx:73
 TPgSQLRow.cxx:74
 TPgSQLRow.cxx:75
 TPgSQLRow.cxx:76
 TPgSQLRow.cxx:77
 TPgSQLRow.cxx:78
 TPgSQLRow.cxx:79
 TPgSQLRow.cxx:80
 TPgSQLRow.cxx:81
 TPgSQLRow.cxx:82
 TPgSQLRow.cxx:83
 TPgSQLRow.cxx:84
 TPgSQLRow.cxx:85
 TPgSQLRow.cxx:86