te::pgis::PreparedQuery Class Reference

A class that implements a prepared query for PostgreSQL data access driver. More...

#include <PreparedQuery.h>

Inheritance diagram for te::pgis::PreparedQuery:
te::da::PreparedQuery

Public Member Functions

void bind (int i, char value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, unsigned char value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, boost::int16_t value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, boost::int32_t value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, boost::int64_t value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, bool value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, float value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, double value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, const std::string &value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, const te::dt::ByteArray &value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, const te::gm::Geometry &value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, const te::rst::Raster &value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, const te::dt::DateTime &value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, const te::da::DataSet &value)
 Binds the i-th parameter of the query to a value. More...
 
void bind (int i, const te::dt::AbstractData &ad)
 Binds the i-th parameter of the query to a value. More...
 
void bind (const std::vector< std::size_t > &propertiesPos, std::size_t offset, te::da::DataSet *d)
 
void bind (const std::vector< std::size_t > &propertiesPos, te::da::DataSet *d)
 
void bind (te::da::DataSet *d)
 
void bindNumeric (int i, const std::string &value)
 Binds the i-th parameter of the query to a value. More...
 
void clear ()
 
void execute ()
 
std::string getName () const
 It returns the prepared query name. More...
 
te::da::DataSourceTransactorgetTransactor () const
 It returns a pointer to the underlying data source transactor. More...
 
void prepare (const te::da::Query &query, const std::vector< te::dt::Property * > &paramTypes)
 It prepares the query that may be used for commands that are used mutiple times (select, insert, update and delete). More...
 
void prepare (const std::string &query, const std::vector< te::dt::Property * > &paramTypes)
 It prepares the query using native dialect. More...
 
void prepare (const std::string &query, const std::vector< int > &paramTypes)
 
 PreparedQuery (Transactor *t, const std::string &pqname)
 
te::da::DataSetquery (te::common::TraverseType travType=te::common::FORWARDONLY, te::common::AccessPolicy rwRole=te::common::RAccess)
 
 ~PreparedQuery ()
 Virtual destructor. More...
 

Private Attributes

std::size_t m_nparams
 
intm_paramFormats
 
intm_paramLengths
 
char ** m_paramValues
 
std::string m_qname
 
PGresultm_result
 
Transactorm_t
 

Detailed Description

A class that implements a prepared query for PostgreSQL data access driver.

Note
Some general notes:
  • bind doesn't need to set length for fixed-size types.
Review pending bind methods (raster, date, array, ...).
We need a numeric type by tomorrow!

Definition at line 68 of file src/terralib/postgis/PreparedQuery.h.

Constructor & Destructor Documentation

te::pgis::PreparedQuery::PreparedQuery ( Transactor t,
const std::string &  pqname 
)

Definition at line 137 of file src/terralib/postgis/PreparedQuery.cpp.

References te::common::Convert2LCase(), and m_qname.

te::pgis::PreparedQuery::~PreparedQuery ( )
virtual

Virtual destructor.

Reimplemented from te::da::PreparedQuery.

Definition at line 149 of file src/terralib/postgis/PreparedQuery.cpp.

References clear().

Member Function Documentation

void te::pgis::PreparedQuery::bind ( int  i,
char  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 230 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, m_paramLengths, and m_paramValues.

Referenced by te::pgis::BindValue().

void te::pgis::PreparedQuery::bind ( int  i,
unsigned char  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 241 of file src/terralib/postgis/PreparedQuery.cpp.

References TE_TR.

void te::pgis::PreparedQuery::bind ( int  i,
boost::int16_t  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 246 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, m_paramLengths, m_paramValues, and te::common::Swap2Bytes().

void te::pgis::PreparedQuery::bind ( int  i,
boost::int32_t  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 261 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, m_paramLengths, m_paramValues, and te::common::Swap4Bytes().

void te::pgis::PreparedQuery::bind ( int  i,
boost::int64_t  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 276 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, m_paramLengths, m_paramValues, and te::common::Swap8Bytes().

void te::pgis::PreparedQuery::bind ( int  i,
bool  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 291 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, m_paramLengths, and m_paramValues.

void te::pgis::PreparedQuery::bind ( int  i,
float  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 304 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, m_paramLengths, m_paramValues, and te::common::Swap4Bytes().

void te::pgis::PreparedQuery::bind ( int  i,
double  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 319 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, m_paramLengths, m_paramValues, and te::common::Swap8Bytes().

void te::pgis::PreparedQuery::bind ( int  i,
const std::string &  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 346 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, and m_paramValues.

void te::pgis::PreparedQuery::bind ( int  i,
const te::dt::ByteArray value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 358 of file src/terralib/postgis/PreparedQuery.cpp.

References te::dt::ByteArray::bytesUsed(), te::dt::ByteArray::getData(), m_paramFormats, m_paramLengths, and m_paramValues.

void te::pgis::PreparedQuery::bind ( int  i,
const te::gm::Geometry value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 370 of file src/terralib/postgis/PreparedQuery.cpp.

References te::gm::Geometry::getWkbSize(), m_paramFormats, m_paramLengths, m_paramValues, and te::pgis::EWKBWriter::write().

void te::pgis::PreparedQuery::bind ( int  i,
const te::rst::Raster value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 387 of file src/terralib/postgis/PreparedQuery.cpp.

References TE_TR.

void te::pgis::PreparedQuery::bind ( int  i,
const te::dt::DateTime value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 392 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramLengths, m_paramValues, and te::dt::AbstractData::toString().

void te::pgis::PreparedQuery::bind ( int  i,
const te::da::DataSet value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 422 of file src/terralib/postgis/PreparedQuery.cpp.

References TE_TR.

void te::pgis::PreparedQuery::bind ( int  i,
const te::dt::AbstractData ad 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Reimplemented from te::da::PreparedQuery.

Definition at line 427 of file src/terralib/postgis/PreparedQuery.cpp.

References TE_TR.

void te::pgis::PreparedQuery::bind ( const std::vector< std::size_t > &  propertiesPos,
std::size_t  offset,
te::da::DataSet d 
)
Note
PostgeSQL driver extended method.

Definition at line 475 of file src/terralib/postgis/PreparedQuery.cpp.

References te::pgis::BindValue().

void te::pgis::PreparedQuery::bind ( const std::vector< std::size_t > &  propertiesPos,
te::da::DataSet d 
)
Note
PostgeSQL driver extended method.

Definition at line 483 of file src/terralib/postgis/PreparedQuery.cpp.

References te::pgis::BindValue().

void te::pgis::PreparedQuery::bind ( te::da::DataSet d)
Note
PostgeSQL driver extended method.

Definition at line 491 of file src/terralib/postgis/PreparedQuery.cpp.

References te::pgis::BindValue(), and m_nparams.

void te::pgis::PreparedQuery::bindNumeric ( int  i,
const std::string &  value 
)
virtual

Binds the i-th parameter of the query to a value.

Parameters
iThe parameter index.
valueThe parameter value.

Implements te::da::PreparedQuery.

Definition at line 334 of file src/terralib/postgis/PreparedQuery.cpp.

References m_paramFormats, and m_paramValues.

Referenced by te::pgis::BindValue().

void te::pgis::PreparedQuery::clear ( )
Note
PostgeSQL driver extended method.

Definition at line 497 of file src/terralib/postgis/PreparedQuery.cpp.

References te::pgis::Transactor::execute(), m_nparams, m_paramFormats, m_paramLengths, m_paramValues, m_qname, m_result, and m_t.

Referenced by prepare(), and ~PreparedQuery().

std::string te::pgis::PreparedQuery::getName ( ) const
virtual

It returns the prepared query name.

Parameters
returnThe prepared query name.

Implements te::da::PreparedQuery.

Definition at line 160 of file src/terralib/postgis/PreparedQuery.cpp.

References m_qname.

te::da::DataSourceTransactor * te::pgis::PreparedQuery::getTransactor ( ) const
virtual

It returns a pointer to the underlying data source transactor.

Returns
A pointer to the underlying data source transactor.

Implements te::da::PreparedQuery.

Definition at line 432 of file src/terralib/postgis/PreparedQuery.cpp.

References m_t.

void te::pgis::PreparedQuery::prepare ( const te::da::Query query,
const std::vector< te::dt::Property * > &  paramTypes 
)
virtual

It prepares the query that may be used for commands that are used mutiple times (select, insert, update and delete).

This command will submit a request to create a prepared query with the given parameters.

Parameters
queryThe query to be prepared.
paramTypesThe list of parameters data type.
Exceptions
ExceptionIt throws an exception if the prepared query can not be created. For example if another prepared query with the same name already exists, this may throws an exception.

Implements te::da::PreparedQuery.

Definition at line 165 of file src/terralib/postgis/PreparedQuery.cpp.

References te::common::BaseVisitable< T, R >::accept(), te::pgis::Connection::getConn(), te::pgis::Transactor::getConnection(), te::pgis::Transactor::getDataSource(), te::pgis::DataSource::getDialect(), and m_t.

void te::pgis::PreparedQuery::prepare ( const std::string &  query,
const std::vector< te::dt::Property * > &  paramTypes 
)
virtual

It prepares the query using native dialect.

This command may be used for commands that are used mutiple times (select, insert, update and delete).

This command will submit a request to create a prepared query with the given parameters.

Parameters
queryThe query to be prepared.
paramTypesThe list of parameters data type.
Exceptions
ExceptionIt throws an exception if the prepared query can not be created. For example if another prepared query with the same name already exists, this may throws an exception.

Implements te::da::PreparedQuery.

Definition at line 177 of file src/terralib/postgis/PreparedQuery.cpp.

References TE_TR.

void te::pgis::PreparedQuery::prepare ( const std::string &  query,
const std::vector< int > &  paramTypes 
)

Member Data Documentation

std::size_t te::pgis::PreparedQuery::m_nparams
private

Definition at line 153 of file src/terralib/postgis/PreparedQuery.h.

Referenced by bind(), clear(), execute(), and prepare().

int* te::pgis::PreparedQuery::m_paramFormats
private

Definition at line 152 of file src/terralib/postgis/PreparedQuery.h.

Referenced by bind(), bindNumeric(), clear(), execute(), and prepare().

int* te::pgis::PreparedQuery::m_paramLengths
private

Definition at line 151 of file src/terralib/postgis/PreparedQuery.h.

Referenced by bind(), clear(), execute(), and prepare().

char** te::pgis::PreparedQuery::m_paramValues
private

Definition at line 150 of file src/terralib/postgis/PreparedQuery.h.

Referenced by bind(), bindNumeric(), clear(), execute(), and prepare().

std::string te::pgis::PreparedQuery::m_qname
private

Definition at line 154 of file src/terralib/postgis/PreparedQuery.h.

Referenced by clear(), execute(), getName(), prepare(), and PreparedQuery().

PGresult* te::pgis::PreparedQuery::m_result
private

Definition at line 149 of file src/terralib/postgis/PreparedQuery.h.

Referenced by clear(), execute(), prepare(), and query().

Transactor* te::pgis::PreparedQuery::m_t
private

Definition at line 148 of file src/terralib/postgis/PreparedQuery.h.

Referenced by clear(), execute(), getTransactor(), prepare(), and query().


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