fatalmind::SQL::RTSQLSelectRow< TM > Class Template Reference

#include <RTSQLSelectRow.hh>

Inherits fatalmind::SQL::RTSQLCommand< TM >, fatalmind::SQL::BindInterface, and fatalmind::SQL::BindOutInterface.

List of all members.


Detailed Description

template<class TM>
class fatalmind::SQL::RTSQLSelectRow< TM >

A command to issue a select statement against an SQL database and fetch only a single row.

If the number of rows returned by the statement is not equal to 1 an exception will be thrown.

The exception might be thrown AFTER the SQLFetcher's process() method was called.

Please refer to the selectrow.cc example to see it in action.

Public Types

typedef PT pool_type

Public Member Functions

 RTSQLSelectRow (const ResourcePool< ResourceType< TM > > &p, const std::string &sql, SQL::SQLFetcher &fetcher=SQL::NopFetcher)
template<typename T>
void bind (const unsigned int pos, const T &val, bool nul=false)
 Binds an actual input value for an placeholder in the SQL statement.
void clearParameters ()
template<typename T>
void bindout (const unsigned int pos, T &val, bool &isnull)
 Specify where the output data of an select statement are to be stored.
template<typename T>
void bindout (const unsigned int pos, T &val, BindOutInterface::BindOutNotNullConstraint=NOTNULL)
void execute (typename ResourceType< TM >::resource_t &hand)
virtual void outputoperator (std::ostream &) const
virtual const Clone * getPlainSpecializedCommand () const
virtual void execute (typename PT::resource_t &rr)=0
 The execute method is the one which actually carries out the work.
Clone * clone () const
template<class Derived>
Derived * clone () const

Static Public Attributes

static bool notnullconstant
static BindOutNotNullConstraint NOTNULL

Protected Member Functions

virtual Clone * DoClone () const
const PT::factory_t & getFactory (const ResourcePool< PT > &p) const


Member Function Documentation

template<class TM>
template<class T>
void fatalmind::SQL::RTSQLSelectRow< TM >::bind ( const unsigned int  pos,
const T &  val,
bool  nul = false 
) [inline]

Binds an actual input value for an placeholder in the SQL statement.

All binding is done by value! this means the passed data are copied to internal storage. Chaning your original copy of your data after passing it to bind() is therefore safe.

Parameters:
pos The position indicator. The number of placeholder (?) in the SQL string. Counted from the left starting at 0.
val the actual value.
nul NULL inidcator, if set to yes the actual value to be bound will be NULL. Please note that you still need to provide a valid value!

Reimplemented from fatalmind::SQL::BindInterface.

template<class TM>
template<class T>
void fatalmind::SQL::RTSQLSelectRow< TM >::bindout ( const unsigned int  pos,
T &  val,
bool &  isnull 
) [inline]

Specify where the output data of an select statement are to be stored.

You need to specify an place where the columns for an select statement are to be stored. After each fetch those variables will be propagated with the actual values received from the select statement. You can also specify a bool which will be used as indicator if the fatched column is NULL. If you omit this third, optional parameter an Exception will be thrown in case a fetched column is NULL.

Parameters:
pos The column number to be bound. Numbering starts with the leftmost column at 0.
val The variable which should contain the value of this column after the fetch. Each time a row is retrieved the according column value value will be available in that variable. The content of the variable will not be changed in case the column is NULL or the execution failed because of an exception. Exclusive access is expected, so there are no synchronization effords taken by the select commands. The variable must be availalbe throughout the whole time of execution.
isnull The optional third argument specifies a bool variable which will be set to true if the fetched column is NULL or to false otherwise. You must supply this indicator variable if you might retrieve NULL for this column. Not supplying an indicator varaible will cause an
Indicator variable required but not supplied.
exception.

Reimplemented from fatalmind::SQL::BindOutInterface.

template<class PT>
virtual void fatalmind::Command< PT >::execute ( typename PT::resource_t &  rr  )  [pure virtual, inherited]

The execute method is the one which actually carries out the work.

This method gets called by ResourcePool with a (valid) plain resource which was obtained from the pool.

On normal execution (no exception) the resource will be free()ed, on abnormal execution (exception) the resource will be failed. If you need to throw an functional exception which should not cause failing of the resource, derive this exception from NoFailoverException.


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

Generated on Mon Jun 9 11:27:04 2008 for ResourcePool by  doxygen 1.5.5