#include <odbc++/preparedstatement.h>
Class 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:
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();
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.
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::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::setBytes (int idx, const 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::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::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::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 std::string & val) |
Sets a parameter value to a string.
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::setAsciiStream (int idx, std::istream * s, int len) |
Sets a parameter value to an ascii stream.
idx | The parameter index, starting at 1 |
val | The stream to assign |
len | The number of bytes available in the stream |
void odbc::PreparedStatement::setBinaryStream (int idx, std::istream * 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::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 |