Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

odbc::PreparedStatement Class Reference

A prepared statement. More...

#include <preparedstatement.h>

Inheritance diagram for odbc::PreparedStatement:

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

Public Methods


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()


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.

bool odbc::PreparedStatement::execute ( )

Executes this statement.

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

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

Sets a parameter value to an ascii stream.

Parameters:
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.

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::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 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::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::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::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::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::setString ( int idx,
const std::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::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

The documentation for this class was generated from the following file:
Go back to the freeodbc++ homepage