odbc::PreparedStatement Class Reference

Inheritance diagram for odbc::PreparedStatement:

odbc::Statement odbc::Statement odbc::ErrorHandler odbc::ErrorHandler odbc::ErrorHandler odbc::ErrorHandler odbc::CallableStatement odbc::CallableStatement List of all members.

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:

 std::auto_ptr<PreparedStatement> pstmt
    =stdauto_ptr<PreparedStatement>(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 62 of file preparedstatement.h.

Public Member Functions

void clearParameters ()
 Clears the parameters.
void clearParameters ()
 Clears the parameters.
bool execute ()
 Executes this statement.
bool execute ()
 Executes this statement.
ResultSetexecuteQuery ()
 Executes this statement, assuming it returns a ResultSet.
ResultSetexecuteQuery ()
 Executes this statement, assuming it returns a ResultSet.
int executeUpdate ()
 Executes this statement, assuming it returns an update count.
int executeUpdate ()
 Executes this statement, assuming it returns an update count.
void setAsciiStream (int idx, ODBCXX_STREAM *s, int len)
 Sets a parameter value to an ascii stream.
void setAsciiStream (int idx, ODBCXX_STREAM *s, int len)
 Sets a parameter value to an ascii stream.
void setBinaryStream (int idx, ODBCXX_STREAM *s, int len)
 Sets a parameter value to a binary stream.
void setBinaryStream (int idx, ODBCXX_STREAM *s, int len)
 Sets a parameter value to a binary stream.
void setBoolean (int idx, bool val)
 Sets a parameter value to a bool.
void setBoolean (int idx, bool val)
 Sets a parameter value to a bool.
void setByte (int idx, signed char val)
 Sets a parameter value to signed char.
void setByte (int idx, signed char val)
 Sets a parameter value to signed char.
void setBytes (int idx, const ODBCXX_BYTES &val)
 Sets a parameter value to a chunk of bytes.
void setBytes (int idx, const ODBCXX_BYTES &val)
 Sets a parameter value to a chunk of bytes.
void setDate (int idx, const Date &val)
 Sets a parameter value to a Date.
void setDate (int idx, const Date &val)
 Sets a parameter value to a Date.
void setDouble (int idx, double val)
 Sets a parameter value to a double.
void setDouble (int idx, double val)
 Sets a parameter value to a double.
void setFloat (int idx, float val)
 Sets a parameter value to a float.
void setFloat (int idx, float val)
 Sets a parameter value to a float.
void setInt (int idx, int val)
 Sets a parameter value to an int.
void setInt (int idx, int val)
 Sets a parameter value to an int.
void setLong (int idx, Long val)
 Sets a parameter value to a Long.
void setLong (int idx, Long val)
 Sets a parameter value to a Long.
void setNull (int idx, int sqlType)
 Sets a parameter value to NULL.
void setNull (int idx, int sqlType)
 Sets a parameter value to NULL.
void setShort (int idx, short val)
 Sets a parameter value to a short.
void setShort (int idx, short val)
 Sets a parameter value to a short.
void setString (int idx, const ODBCXX_STRING &val)
 Sets a parameter value to a string.
void setString (int idx, const ODBCXX_STRING &val)
 Sets a parameter value to a string.
void setTime (int idx, const Time &val)
 Sets a parameter value to a Time.
void setTime (int idx, const Time &val)
 Sets a parameter value to a Time.
void setTimestamp (int idx, const Timestamp &val)
 Sets a parameter value to a Timestamp.
void setTimestamp (int idx, const Timestamp &val)
 Sets a parameter value to a Timestamp.
virtual ~PreparedStatement ()
 Destructor.
virtual ~PreparedStatement ()
 Destructor.

Protected Attributes

int defaultDirection_
std::vector< int > directions_
std::vector< int > directions_
size_t numParams_
bool paramsBound_
Rowset * rowset_
Rowset * rowset_
ODBCXX_STRING sql_


Member Function Documentation

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.

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.

bool odbc::PreparedStatement::execute (  ) 

Executes this statement.

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

bool odbc::PreparedStatement::execute (  ) 

Executes this statement.

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

ResultSet* odbc::PreparedStatement::executeQuery (  ) 

Executes this statement, assuming it returns a ResultSet.

Example: std::auto_ptr<ResultSet> rs = std::auto_ptr<ResultSet>(pstmt->executeQuery(s));

ResultSet* odbc::PreparedStatement::executeQuery (  ) 

Executes this statement, assuming it returns a ResultSet.

Example: std::auto_ptr<ResultSet> rs = std::auto_ptr<ResultSet>(pstmt->executeQuery(s));

Referenced by ODBCTapeStream::Open().

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

Sets a parameter value to an ascii stream.

Parameters:
idx The parameter index, starting at 1
s The stream to assign
len The number of bytes available in the stream

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

Sets a parameter value to an ascii stream.

Parameters:
idx The parameter index, starting at 1
s The stream to assign
len The number of bytes available in the stream

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

Sets a parameter value to a binary stream.

Parameters:
idx The parameter index, starting at 1
s The stream to assign
len The number of bytes available in the stream

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

Sets a parameter value to a binary stream.

Parameters:
idx The parameter index, starting at 1
s The stream to assign
len The number of bytes available in the stream

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

Sets a parameter value to a bool.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a bool.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to signed char.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to signed char.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a chunk of bytes.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a chunk of bytes.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a Date.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a Date.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a double.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a double.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a float.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a float.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to an int.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to an int.

Parameters:
idx The parameter index, starting at 1
val The value to set

Referenced by ODBCTapeStream::Write().

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

Sets a parameter value to a Long.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a Long.

Parameters:
idx The parameter index, starting at 1
val The value to set

Referenced by ODBCTapeStream::PrintHeader().

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

Sets a parameter value to NULL.

Parameters:
idx The parameter index, starting at 1
sqlType The SQL type of the parameter
See also:
Types

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

Sets a parameter value to NULL.

Parameters:
idx The parameter index, starting at 1
sqlType The SQL type of the parameter
See also:
Types

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

Sets a parameter value to a short.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a short.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a string.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a string.

Parameters:
idx The parameter index, starting at 1
val The value to set

Referenced by ODBCTapeStream::PrintHeader(), and ODBCTapeStream::Write().

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

Sets a parameter value to a Time.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a Time.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a Timestamp.

Parameters:
idx The parameter index, starting at 1
val The value to set

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

Sets a parameter value to a Timestamp.

Parameters:
idx The parameter index, starting at 1
val The value to set


The documentation for this class was generated from the following files:
GridLAB-DTM Version 1.0
An open-source project initiated by the US Department of Energy