Inheritance diagram for odbc::PreparedStatement:
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();
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. | |
ResultSet * | executeQuery () |
Executes this statement, assuming it returns a ResultSet. | |
ResultSet * | executeQuery () |
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_ |
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.
bool odbc::PreparedStatement::execute | ( | ) |
Executes this statement.
ResultSet* odbc::PreparedStatement::executeQuery | ( | ) |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
idx | The parameter index, starting at 1 | |
sqlType | The SQL type of the parameter |
void odbc::PreparedStatement::setNull | ( | int | idx, | |
int | sqlType | |||
) |
Sets a parameter value to NULL.
idx | The parameter index, starting at 1 | |
sqlType | The SQL type of the parameter |
void odbc::PreparedStatement::setShort | ( | int | idx, | |
short | val | |||
) |
Sets a parameter value to a short.
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.
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.
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.
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.
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.
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.
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.
idx | The parameter index, starting at 1 | |
val | The value to set |