Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
odbc::PreparedStatement Class Reference

#include <RDBC/blob/master/include/RDBC/odbc++/preparedstatement.h>

+ Inheritance diagram for odbc::PreparedStatement:
+ Collaboration diagram for odbc::PreparedStatement:

Public Member Functions

virtual ~PreparedStatement ()
 
void clearParameters ()
 
bool execute ()
 
ResultSetexecuteQuery ()
 
int executeUpdate ()
 
bool execute (const ODBCXX_STRING &)
 
ResultSetexecuteQuery (const ODBCXX_STRING &)
 
int executeUpdate (const ODBCXX_STRING &)
 
void setDouble (int idx, double val)
 
void setBoolean (int idx, bool val)
 
void setByte (int idx, signed char val)
 
void setBytes (int idx, const ODBCXX_BYTES &val)
 
void setDate (int idx, const Date &val)
 
void setFloat (int idx, float val)
 
void setInt (int idx, int val)
 
void setLong (int idx, Long val)
 
void setShort (int idx, short val)
 
void setString (int idx, const ODBCXX_STRING &val)
 
void setTime (int idx, const Time &val)
 
void setTimestamp (int idx, const Timestamp &val)
 
void setAsciiStream (int idx, ODBCXX_STREAM *s, int len)
 
void setBinaryStream (int idx, ODBCXX_STREAM *s, int len)
 
void setNull (int idx, int sqlType)
 
- Public Member Functions inherited from odbc::Statement
virtual ~Statement ()
 
ConnectiongetConnection ()
 
void cancel ()
 
int getUpdateCount ()
 
ResultSetgetResultSet ()
 
bool getMoreResults ()
 
void setCursorName (const ODBCXX_STRING &name)
 
int getFetchSize ()
 
void setFetchSize (int size)
 
int getResultSetConcurrency ()
 
int getResultSetType ()
 
int getQueryTimeout ()
 
void setQueryTimeout (int seconds)
 
int getMaxRows ()
 
void setMaxRows (int maxRows)
 
int getMaxFieldSize ()
 
void setMaxFieldSize (int maxFieldSize)
 
void setEscapeProcessing (bool on)
 
bool getEscapeProcessing ()
 
- Public Member Functions inherited from odbc::ErrorHandler
void clearWarnings ()
 
WarningListgetWarnings ()
 
virtual ~ErrorHandler ()
 

Protected Member Functions

 PreparedStatement (Connection *con, SQLHSTMT hstmt, const ODBCXX_STRING &sql, int resultSetType, int resultSetConcurrency, int defaultDirection=SQL_PARAM_INPUT)
 
void _bindParams ()
 
void _unbindParams ()
 
void _checkParam (int idx, int *allowed, int numAllowed, int defPrec, int defScale)
 
- Protected Member Functions inherited from odbc::Statement
const DriverInfo * _getDriverInfo () const
 
 Statement (Connection *con, SQLHSTMT hstmt, int resultSetType, int resultSetConcurrency)
 
SQLUINTEGER _getNumericOption (SQLINTEGER optnum)
 
ODBCXX_STRING _getStringOption (SQLINTEGER optnum)
 
void _setNumericOption (SQLINTEGER optnum, SQLUINTEGER value)
 
void _setStringOption (SQLINTEGER optnum, const ODBCXX_STRING &value)
 
bool _checkForResults ()
 
ResultSet_getResultSet (bool hideMe=false)
 
void _beforeExecute ()
 
void _afterExecute ()
 
- Protected Member Functions inherited from odbc::ErrorHandler
void _postWarning (SQLWarning *w)
 
void _checkErrorODBC2 (SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLRETURN r, const ODBCXX_STRING &what)
 
void _checkStmtError (SQLHSTMT hstmt, SQLRETURN r, const char *what="")
 
void _checkConError (SQLHDBC hdbc, SQLRETURN r, const char *what="")
 
void _checkEnvError (SQLHENV henv, SQLRETURN r, const char *what="")
 
 ErrorHandler (bool collectWarnings=true)
 

Protected Attributes

ODBCXX_STRING sql_
 
Rowset * rowset_
 
size_t numParams_
 
std::vector< int > directions_
 
int defaultDirection_
 
bool paramsBound_
 
- Protected Attributes inherited from odbc::Statement
Connectionconnection_
 
SQLHSTMT hstmt_
 
int lastExecute_
 

Private Member Functions

void _prepare ()
 
void _setupParams ()
 

Friends

class Connection
 

Detailed Description

A prepared statement.

A prepared statement is precompiled by the driver and/or datasource, and can be executed multiple times with different parameters.

Parameters are set using the setXXX methods. Note that it's advisable to use the set method compatible with the parameter's SQL type - for example, for a Types::DATE, setDate() should be used. Question marks ("?") are used in the SQL statement to represent a parameter, for example:

PreparedStatement* pstmt=con->prepareStatement
   ("INSERT INTO SOMETABLE(AN_INTEGER_COL,A_VARCHAR_COL) VALUES(?,?)");
pstmt->setInt(1,10);
pstmt->setString(2,"Hello, world!");
int affectedRows=pstmt->executeUpdate();
See Also
Connection::prepareStatement()

Definition at line 61 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 61 of file preparedstatement.h

Constructor & Destructor Documentation

odbc::PreparedStatement::PreparedStatement ( Connection con,
SQLHSTMT  hstmt,
const ODBCXX_STRING sql,
int  resultSetType,
int  resultSetConcurrency,
int  defaultDirection = SQL_PARAM_INPUT 
)
protected
virtual odbc::PreparedStatement::~PreparedStatement ( )
virtual

Destructor

Member Function Documentation

void odbc::PreparedStatement::_bindParams ( )
protected
void odbc::PreparedStatement::_checkParam ( int  idx,
int *  allowed,
int  numAllowed,
int  defPrec,
int  defScale 
)
protected
void odbc::PreparedStatement::_prepare ( )
private
void odbc::PreparedStatement::_setupParams ( )
private
void odbc::PreparedStatement::_unbindParams ( )
protected
void odbc::PreparedStatement::clearParameters ( )

Clears the parameters.

The set of parameters stays around until they are set again. To explicitly clear them (and thus release buffers held by the driver), this method should be called.

Referenced by ODBCPreparedStatement::ClearParameters(), and ODBCCallableStatement::ClearParameters().

+ Here is the caller graph for this function:

bool odbc::PreparedStatement::execute ( )

Executes this statement.

Returns
True if the result is a ResultSet, false if it's an update count or unknown.

Referenced by ODBCPreparedStatement::Execute(), and ODBCCallableStatement::Execute().

+ Here is the caller graph for this function:

bool odbc::PreparedStatement::execute ( const ODBCXX_STRING )
inlinevirtual

Reimplement virtual signatures in base class Statement that were hidden by argumentless versions above. 2003-05-02 rhatc.nosp@m.her@.nosp@m.fnal..nosp@m.gov

Reimplemented from odbc::Statement.

Definition at line 120 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 120 of file preparedstatement.h

References execute().

Referenced by execute().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ResultSet* odbc::PreparedStatement::executeQuery ( )

Executes this statement, assuming it returns a ResultSet.

Referenced by ODBCPreparedStatement::ExecuteQuery(), ODBCCallableStatement::ExecuteQuery(), and OnCalServer::SyncCalibTimeStampsToOnCal().

+ Here is the caller graph for this function:

ResultSet* odbc::PreparedStatement::executeQuery ( const ODBCXX_STRING sql)
inlinevirtual

Execute an SQL statement, expected to return a resultset.

Parameters
sqlThe string to execute
Returns
A ResultSet object.

Reimplemented from odbc::Statement.

Definition at line 122 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 122 of file preparedstatement.h

References executeQuery().

Referenced by executeQuery().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int odbc::PreparedStatement::executeUpdate ( )

Executes this statement, assuming it returns an update count

Referenced by ODBCPreparedStatement::ExecuteUpdate(), ODBCCallableStatement::ExecuteUpdate(), OnCalServer::SyncCalibTimeStampsToOnCal(), and OnCalServer::SyncOncalTimeStampsToRunDB().

+ Here is the caller graph for this function:

int odbc::PreparedStatement::executeUpdate ( const ODBCXX_STRING sql)
inlinevirtual

Execute an SQL statement, expected to return an update count.

Returns
The number of affected rows

Reimplemented from odbc::Statement.

Definition at line 124 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 124 of file preparedstatement.h

References executeUpdate().

Referenced by executeUpdate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setAsciiStream ( int  idx,
ODBCXX_STREAM s,
int  len 
)

Sets a parameter value to an ascii stream.

Parameters
idxThe parameter index, starting at 1
valThe stream to assign
lenThe number of bytes available in the stream

Referenced by ODBCPreparedStatement::SetAsciiStream(), and ODBCCallableStatement::SetAsciiStream().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setBinaryStream ( int  idx,
ODBCXX_STREAM s,
int  len 
)

Sets a parameter value to a binary stream.

Parameters
idxThe parameter index, starting at 1
sThe stream to assign
lenThe number of bytes available in the stream

Referenced by ODBCPreparedStatement::SetBinaryStream(), and ODBCCallableStatement::SetBinaryStream().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setBoolean ( int  idx,
bool  val 
)

Sets a parameter value to a bool

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetBoolean(), and ODBCCallableStatement::SetBoolean().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setByte ( int  idx,
signed char  val 
)

Sets a parameter value to signed char

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetByte(), and ODBCCallableStatement::SetByte().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setBytes ( int  idx,
const ODBCXX_BYTES val 
)

Sets a parameter value to a chunk of bytes

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetBytes(), and ODBCCallableStatement::SetBytes().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setDate ( int  idx,
const Date val 
)

Sets a parameter value to a Date

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetDate(), and ODBCCallableStatement::SetDate().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setDouble ( int  idx,
double  val 
)

Sets a parameter value to a double

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetDouble(), and ODBCCallableStatement::SetDouble().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setFloat ( int  idx,
float  val 
)

Sets a parameter value to a float

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetFloat(), and ODBCCallableStatement::SetFloat().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setInt ( int  idx,
int  val 
)

Sets a parameter value to an int

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetInt(), ODBCCallableStatement::SetInt(), and OnCalServer::SyncCalibTimeStampsToOnCal().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setLong ( int  idx,
Long  val 
)

Sets a parameter value to a Long

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetLong(), ODBCCallableStatement::SetLong(), and OnCalServer::SyncOncalTimeStampsToRunDB().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setNull ( int  idx,
int  sqlType 
)

Sets a parameter value to NULL

Parameters
idxThe parameter index, starting at 1
sqlTypeThe SQL type of the parameter
See Also
Types

Referenced by ODBCPreparedStatement::SetNull(), and ODBCCallableStatement::SetNull().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setShort ( int  idx,
short  val 
)

Sets a parameter value to a short

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetShort(), and ODBCCallableStatement::SetShort().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setString ( int  idx,
const ODBCXX_STRING val 
)

Sets a parameter value to a string

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetString(), and ODBCCallableStatement::SetString().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setTime ( int  idx,
const Time val 
)

Sets a parameter value to a Time

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetTime(), and ODBCCallableStatement::SetTime().

+ Here is the caller graph for this function:

void odbc::PreparedStatement::setTimestamp ( int  idx,
const Timestamp val 
)

Sets a parameter value to a Timestamp

Parameters
idxThe parameter index, starting at 1
valThe value to set

Referenced by ODBCPreparedStatement::SetTimestamp(), and ODBCCallableStatement::SetTimestamp().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class Connection
friend

Definition at line 62 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 62 of file preparedstatement.h

Member Data Documentation

int odbc::PreparedStatement::defaultDirection_
protected

Definition at line 74 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 74 of file preparedstatement.h

std::vector<int> odbc::PreparedStatement::directions_
protected

Definition at line 73 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 73 of file preparedstatement.h

size_t odbc::PreparedStatement::numParams_
protected

Definition at line 72 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 72 of file preparedstatement.h

bool odbc::PreparedStatement::paramsBound_
protected

Definition at line 75 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 75 of file preparedstatement.h

Rowset* odbc::PreparedStatement::rowset_
protected

Definition at line 71 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 71 of file preparedstatement.h

ODBCXX_STRING odbc::PreparedStatement::sql_
protected

Definition at line 69 of file preparedstatement.h.

View newest version in sPHENIX GitHub at line 69 of file preparedstatement.h


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