Class CStatement

There are some ways to use CStatement object:

Only one CResultSet per CStatement can be open at any point in time. Therefore, if the reading of one CResultSet is interleaved with the reading of another, each must have been generated by different CStatements. All statement execute methods implicitly close a statment's current CResultSet if an open one exists.

Note: The setXXX methods for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type Integer then setInt should be used.

See Also:

createStatement, CResultSet


Constructor Summary
CStatement(CConnection* connection)
Constructs a CStatement object. Your derived class must provide a constructor that calls this one.

 

Method Summary

CResultSet*

executeQuery()
A prepared SQL query is executed and its resultset is returned.

CResultSet*

executeQuery(const char*)
Execute a SQL statement that returns a single resultset.

 int

executeUpdate(const char*)
Execute a SQL INSERT, UPDATE or DELETE statement.

int

executeUpdate()
Execute a SQL INSERT, UPDATE or DELETE statement.

bool

isStmSelect()
Return the type of this statement.

int

prepareStatement(const char*)
A SQL statement with or without IN parameters can be pre-compiled and stored in a CStatement object.

int

setDate(const short, const COCIDate*)
Set a parameter to a Oracle Date value.

int

setDouble(const short, const double*)
Set a parameter to a Oracle Double value.

int

setFloat(const short, const float*)
Set a parameter to a Oracle Float value.

int

setInt(const short, const int*)
Set a parameter to a Oracle Integer value.

int

setString(const short, const char*)
Set a parameter to a Oracle String value.

 

Constructor Detail

CStatement::CStatement

CStatement(CConnection* connection);

Constructs a CStatement object. You can either use CStatement directly or derive an application-specific class from CStatement.
Parameters:
connection - the CConnection handle.

 

Method Detail

CStatement::executeQuery

CResultSet* executeQuery();

A prepared SQL query is executed and its resultset is returned.
Returns:
pointer to a CResultSet that contains the data produced by the query.

CStatement::executeQuery

CResultSet* executeQuery(const char* sql);

Execute a SQL statement that returns a single resultset.
Parameters:
sql - typically this is a static SQL SELECT statement.
Returns:
pointer to a CResultSet that contains the data produced by the query.

CStatement::executeUpdate

int executeUpdate(const char* sql);

Execute a SQL INSERT, UPDATE or DELETE statement.
Parameters:
sql - a SQL INSERT, UPDATE or DELETE statement or a SQL statement that returns nothing.
Returns:
either the error code or 0 for SQL success.

CStatement::executeUpdate

int executeUpdate();

Execute a SQL INSERT, UPDATE or DELETE statement.
Returns:
either the error code or 0 for SQL success.

CStatement::isStmSelect

bool isStmSelect();

Return the type of this statement.
Returns:
nonzero if the OCI statement type is SELECT; otherwise 0.

CStatement::prepareStatement

int prepareStatement(const char* sql);

A SQL statement with or without IN parameters can be pre-compiled and stored in a CStatement object.
Parameters:
sql - a SQL statement that may contain one or more '?' IN parameter placeholders.
Returns:
either the error code or 0 for SQL success.

CStatement::setDate

int setDate(const short index, const COCIDate* val);

Set a parameter to a Oracle Date value.
Parameters:
index - the first parameter is 1, the second is 2, ...
val - the parameter value.
Returns:
either the error code or 0 for SQL success.

CStatement::setDouble

int setDouble(const short index, const const double* val);

Set a parameter to a Oracle Double value.
Parameters:
index - the first parameter is 1, the second is 2, ...
val - the parameter value.
Returns:
either the error code or 0 for SQL success.

CStatement::setFloat

int setFloat(const short index, const const float* val);

Set a parameter to a Oracle Float value.
Parameters:
index - the first parameter is 1, the second is 2, ...
val - the parameter value.
Returns:
either the error code or 0 for SQL success.

CStatement::setInt

int setInt(const short index, const const int* val);

Set a parameter to a Oracle Integer value.
Parameters:
index - the first parameter is 1, the second is 2, ...
val - the parameter value.
Returns:
either the error code or 0 for SQL success.

CStatement::setString

int setString(const short index, const const char* val);

Set a parameter to a Oracle String value.
Parameters:
index - the first parameter is 1, the second is 2, ...
val - the parameter value.
Returns:
either the error code or 0 for SQL success.

Submit comments/suggestions about OCL.
Copyright 2001 Sergey Yakovlev. All Rights Reserved.