xvr2::SQL::ResultSet Class Reference

#include <ResultSet.h>

Inheritance diagram for xvr2::SQL::ResultSet:

Inheritance graph
[legend]

List of all members.


Detailed Description

Implements result set handling from SELECT-type queries.

A ResultSet is like a table which holds the query result rows, in order to read such information you might have done something like:

  xvr2::SQL::Connection *conn;
  .
  //Connect to a database successfully
  .
  //You will always obtain a ResultSet from query
  xvr2::SQL::ResultSet *result = conn->query("SELECT * FROM table");
  //Retrieve each row in the set until fetchRow returns 0
  while(result->fetchRow()){
     //Read a colum from the row
     std::cout << result->get(0).toString();
     .
     //Do whatever else you need with the rows in your set.
     .
  }
  delete result; //Release ResultSet resources

Definition at line 46 of file ResultSet.h.


Public Member Functions

 ResultSet (Driver *drv, void *__rhandle, bool __status)
 ResultSet (Driver *drv, void *__rhandle, bool __status, UInt64 afrows)
 ~ResultSet ()
bool status ()
 Will hold the status of the previous query, if it was a query or not.
const int numRows ()
 Returns the number of retrieved rows in the ResultSet.
const int numCols ()
 Returns the number of retrieved columns in the ResultSet.
const StringgetColName (const int index)
 Returns the name of a column.
const FieldgetRow ()
 This will return the current retrieved row as an array of Field elements.
const Fieldget (const int index)
 This will return the value of the given column: index in the currently retrieved row.
const Fieldget (const char *colname)
 This will return the value of the given column name: colname in the currently retrieved row.
const Fieldget (const String &colname)
 This will return the value of the given column name: colname in the currently retrieved row.
const FieldfetchRow ()
 Retrieves a row from an SQL result set.
const FieldfetchNextRow ()
 Use this method to move to next row to be read from the result stream.
const UInt64 affectedRows ()
 In the case you ran an update, delete or another query which does not return a ResultSet but alters the content of a tables, this method will tell you how many rows got affected as a result of the operation.
const char * errorMessage ()
 Returns the error message as returned by the RDBMS after this query was sent.
virtual const char * getClassName ()
 Returns the name of the current class.
virtual std::string toString ()

Static Public Member Functions

static void debugmsg (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__)
 Will print a debug message to the screen.
static void debugmsgln (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__)

Protected Attributes

bool _status
void * r_handle
 A generic handle to the driver's specific resultset object.
Driverdriver
 Points to the SQL driver in use.
Fieldrow
 Holds the currect row in the stream.
int ncols
UInt64 afrows
bool is_a_select
int ridx
std::string __cls_name

Friends

std::ostream & operator<< (std::ostream &stream, const Object &s)

Constructor & Destructor Documentation

xvr2::SQL::ResultSet::ResultSet ( Driver drv,
void *  __rhandle,
bool  __status 
)

xvr2::SQL::ResultSet::ResultSet ( Driver drv,
void *  __rhandle,
bool  __status,
UInt64  afrows 
)

xvr2::SQL::ResultSet::~ResultSet (  ) 


Member Function Documentation

bool xvr2::SQL::ResultSet::status (  ) 

Will hold the status of the previous query, if it was a query or not.

const int xvr2::SQL::ResultSet::numRows (  ) 

Returns the number of retrieved rows in the ResultSet.

const int xvr2::SQL::ResultSet::numCols (  ) 

Returns the number of retrieved columns in the ResultSet.

const String& xvr2::SQL::ResultSet::getColName ( const int  index  ) 

Returns the name of a column.

const Field* xvr2::SQL::ResultSet::getRow (  ) 

This will return the current retrieved row as an array of Field elements.

const Field& xvr2::SQL::ResultSet::get ( const int  index  ) 

This will return the value of the given column: index in the currently retrieved row.

const Field& xvr2::SQL::ResultSet::get ( const char *  colname  ) 

This will return the value of the given column name: colname in the currently retrieved row.

const Field& xvr2::SQL::ResultSet::get ( const String colname  ) 

This will return the value of the given column name: colname in the currently retrieved row.

const Field* xvr2::SQL::ResultSet::fetchRow (  ) 

Retrieves a row from an SQL result set.

After you get a ResultSet as a result from a Connection::query call you must call this method so you can start reading the result set iteratively until you reach the last row in the set.

Returns:
An array of Field elements each one matching a column from your ResultSet or 0 if there are no more rows to read from the ResultSet.

const Field* xvr2::SQL::ResultSet::fetchNextRow (  ) 

Use this method to move to next row to be read from the result stream.

This method will also return an array of Field elements representing the cells of the current row.

In case you reached the last row this method will return NULL instead of the Field array.

Deprecated:
Use fetchrow instead.

const UInt64 xvr2::SQL::ResultSet::affectedRows (  ) 

In the case you ran an update, delete or another query which does not return a ResultSet but alters the content of a tables, this method will tell you how many rows got affected as a result of the operation.

const char* xvr2::SQL::ResultSet::errorMessage (  ) 

Returns the error message as returned by the RDBMS after this query was sent.

virtual const char* xvr2::Object::getClassName (  )  [virtual, inherited]

Returns the name of the current class.

static void xvr2::Object::debugmsg ( Object obj,
const char *  msg,
int  linenumber = __LINE__,
const char *  srcfile = __FILE__ 
) [static, inherited]

Will print a debug message to the screen.

static void xvr2::Object::debugmsgln ( Object obj,
const char *  msg,
int  linenumber = __LINE__,
const char *  srcfile = __FILE__ 
) [static, inherited]

virtual std::string xvr2::Object::toString (  )  [virtual, inherited]


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const Object s 
) [friend, inherited]


Member Data Documentation

Definition at line 49 of file ResultSet.h.

void* xvr2::SQL::ResultSet::r_handle [protected]

A generic handle to the driver's specific resultset object.

Definition at line 51 of file ResultSet.h.

Points to the SQL driver in use.

Definition at line 53 of file ResultSet.h.

Holds the currect row in the stream.

Definition at line 55 of file ResultSet.h.

int xvr2::SQL::ResultSet::ncols [protected]

Definition at line 56 of file ResultSet.h.

Definition at line 57 of file ResultSet.h.

Definition at line 58 of file ResultSet.h.

int xvr2::SQL::ResultSet::ridx [protected]

Definition at line 59 of file ResultSet.h.

std::string xvr2::Object::__cls_name [protected, inherited]

Definition at line 30 of file Object.h.


The documentation for this class was generated from the following file:

Generated on Fri Jun 20 22:56:06 2008 for X-VR2 SDK by  doxygen 1.5.5