an OCI SQL statement More...
#include <ocipl.h>


Public Types | |
| typedef OciHandle< OCIStmt > | super |
| typedef OCIStmt | HandleType |
Public Member Functions | |
| SqlStatement (OciConnection &conn, int bulk_rows=g_OCIPL_BULK_ROWS) | |
| SqlStatement (OciConnection &conn, const tstring &sql, ub4 lang=OCI_NTV_SYNTAX, int bulk_rows=g_OCIPL_BULK_ROWS) | |
| SqlStatement (OciConnection &conn, const tstring &sql, const char *file, int line, ub4 lang=OCI_NTV_SYNTAX, int bulk_rows=g_OCIPL_BULK_ROWS) | |
| virtual | ~SqlStatement () |
| bool | eof () const |
| void | prepare (const tstring &sql, ub4 lang=OCI_NTV_SYNTAX) |
| virtual void | prepare (const tstring &sql, const char *file, int line, ub4 lang=OCI_NTV_SYNTAX) |
| int | get_stmt_type () const |
| const tstring & | get_last_sql () const |
| const char * | get_last_file () const |
| int | get_last_line () const |
| ub4 | fetched_rows () const |
| ub4 | row_count () const |
| int | result_buffers () const |
| OCIBind * | bind_input (int idx, BindInput par, OCIBind *bindp=NULL) |
| OCIBind * | bind_input (const tstring &name, BindInput par, OCIBind *bindp=NULL) |
| OCIBind * | bind_output (int idx, BindOutput par, OCIBind *bindp=NULL) |
| OCIBind * | bind_output (const tstring &name, BindOutput par, OCIBind *bindp=NULL) |
| OCIBind * | bind_inout (int idx, BindOutput par, OCIBind *bindp=NULL) |
| OCIBind * | bind_inout (const tstring &name, BindOutput par, OCIBind *bindp=NULL) |
| OCIDefine * | bind_result (int idx, DefinePar par, OCIDefine *defnp=NULL) |
| void | bind_result (struct SqlRecord &rec) |
| void | execute () |
| void | execute (ub4 rows, ub4 mode=OCI_DEFAULT) |
| void | execute (const tstring &sql) |
| void | execute (const tstring &sql, const char *file, int line) |
| void | execute (const tstring &sql, ub4 rows) |
| void | execute (const tstring &sql, const char *file, int line, ub4 rows) |
| void | ensure_execute () |
| void | execute_fetch (ub4 mode=OCI_DEFAULT) |
| void | execute_fetch (const tstring &sql, ub4 lang=OCI_NTV_SYNTAX, ub4 mode=OCI_DEFAULT) |
| void | execute_fetch (const tstring &sql, const char *file, int line, ub4 lang=OCI_NTV_SYNTAX, ub4 mode=OCI_DEFAULT) |
| void | fetch (ub4 rows=(ub4)-1) |
| bool | next () |
| int | first_bulk () |
| int | next_bulk () |
| ub4 | get_column_count () const |
| void | get_column_type (int idx, ColumnType &info) const |
| void | print_results (tostream &out, bool header=true) |
| void | print_results (const tstring &sql, tostream &out, bool header=true) |
| const SqlResult & | get_result () |
| SqlResult * | operator-> () |
| void | alloc () |
| void | destroy () |
| void | set_attribute (ub4 attrtype, const tstring &str) |
| void | set_attribute (ub4 attrtype, ub4 value) |
| void | set_attribute (ATTR &attr) |
| void | get_attribute (dvoid *attributep, ub4 *sizep, ub4 attrtype) |
| void | set_attribute_handle (ub4 attrtype, void *handle) |
| operator HandleType * () | |
Static Public Member Functions | |
| static ub4 | get_type_id () |
| static ub4 | get_attr_id () |
Public Attributes | |
| OciEnv & | _env |
Protected Types | |
| enum | _NO_ALLOC_ { NO_HANDLE_ALLOC } |
| enum | STATE { UNINITIALIZED = 0, PREPARED = 1, DEFINED = 2, EXECUTED = 4, FETCHED = 8, EOF_DATA = 16, STMT_ERROR = 32 } |
Protected Member Functions | |
| SqlStatement (OciConnection &conn, int bulk_rows, _NO_ALLOC_) | |
| void | execute_internal (ub4 rows, ub4 mode) |
Protected Attributes | |
| OciContext & | _ctx |
| int | _state |
| tstring | _last_sql |
| const char * | _last_file |
| int | _last_line |
| struct SqlResult * | _res |
| int | _stmt_type |
| int | _bulk_rows |
| int | _result_buffers |
| ub4 | _last_row |
| ub4 | _last_fetched_row |
| HandleType * | _handle |
an OCI SQL statement
Definition at line 3015 of file ocipl.h.
typedef OCIStmt OCIPL::OciHandle< OCIStmt >::HandleType [inherited] |
| typedef OciHandle<OCIStmt> OCIPL::SqlStatement::super |
Reimplemented from OCIPL::OciHandle< OCIStmt >.
enum OCIPL::SqlStatement::_NO_ALLOC_ [protected] |
enum OCIPL::SqlStatement::STATE [protected] |
Definition at line 3092 of file ocipl.h.
{
UNINITIALIZED=0,
PREPARED=1, DEFINED=2, EXECUTED=4, FETCHED=8,
EOF_DATA=16, STMT_ERROR=32
};
| OCIPL::SqlStatement::SqlStatement | ( | OciConnection & | conn, |
| int | bulk_rows = g_OCIPL_BULK_ROWS |
||
| ) | [inline] |
Definition at line 3019 of file ocipl.h.
: super(conn._env), _ctx(conn._ctx), _state(UNINITIALIZED), _last_file(NULL), _last_line(-1), _res(NULL), _stmt_type(-1), _bulk_rows(bulk_rows), _result_buffers(0), _last_row((ub4)-1), _last_fetched_row((ub4)-1) { }
| OCIPL::SqlStatement::SqlStatement | ( | OciConnection & | conn, |
| const tstring & | sql, | ||
| ub4 | lang = OCI_NTV_SYNTAX, |
||
| int | bulk_rows = g_OCIPL_BULK_ROWS |
||
| ) | [inline] |
Definition at line 3035 of file ocipl.h.
: super(conn._env), _ctx(conn._ctx), _state(UNINITIALIZED), _last_file(NULL), _last_line(-1), _res(NULL), _stmt_type(-1), _bulk_rows(bulk_rows), _result_buffers(0), _last_row((ub4)-1), _last_fetched_row((ub4)-1) { prepare(sql, lang); }
| OCIPL::SqlStatement::SqlStatement | ( | OciConnection & | conn, |
| const tstring & | sql, | ||
| const char * | file, | ||
| int | line, | ||
| ub4 | lang = OCI_NTV_SYNTAX, |
||
| int | bulk_rows = g_OCIPL_BULK_ROWS |
||
| ) | [inline] |
Definition at line 3052 of file ocipl.h.
: super(conn._env), _ctx(conn._ctx), _state(UNINITIALIZED), _last_file(NULL), _last_line(-1), _res(NULL), _stmt_type(-1), _bulk_rows(bulk_rows), _result_buffers(0), _last_row((ub4)-1), _last_fetched_row((ub4)-1) { prepare(sql, file, line, lang); }
| OCIPL::SqlStatement::~SqlStatement | ( | ) | [virtual] |
| OCIPL::SqlStatement::SqlStatement | ( | OciConnection & | conn, |
| int | bulk_rows, | ||
| _NO_ALLOC_ | |||
| ) | [inline, protected] |
Definition at line 3075 of file ocipl.h.
: super(conn._env, NULL), _ctx(conn._ctx), _state(UNINITIALIZED), _last_file(NULL), _last_line(-1), _res(NULL), _stmt_type(-1), _bulk_rows(bulk_rows), _result_buffers(0), _last_row((ub4)-1), _last_fetched_row((ub4)-1) { }
| void OCIPL::OciHandle< OCIStmt >::alloc | ( | ) | [inline, inherited] |
Definition at line 596 of file ocipl.h.
{
if (_handle)
destroy();
sword res = OCIHandleAlloc(_env, (dvoid**)&_handle, super::get_type_id(), 0, 0);
oci_check_error(_env, res);
}
| OCIBind* OCIPL::SqlStatement::bind_inout | ( | int | idx, |
| BindOutput | par, | ||
| OCIBind * | bindp = NULL |
||
| ) | [inline] |
Definition at line 3213 of file ocipl.h.
{
return bind_output(idx, par, bindp);
}
| OCIBind* OCIPL::SqlStatement::bind_inout | ( | const tstring & | name, |
| BindOutput | par, | ||
| OCIBind * | bindp = NULL |
||
| ) | [inline] |
Definition at line 3218 of file ocipl.h.
{
return bind_output(name, par, bindp);
}
| OCIBind* OCIPL::SqlStatement::bind_input | ( | int | idx, |
| BindInput | par, | ||
| OCIBind * | bindp = NULL |
||
| ) | [inline] |
Definition at line 3166 of file ocipl.h.
References OCIPL::BindInput::dty, OCIPL::BindInput::indp, OCIPL::oci_check_error(), OCIPL::BindInput::value_sz, and OCIPL::BindInput::valuep.
Referenced by OCIPL::SqlVariantArray::bind_input().
{
sword res = OCIBindByPos(_handle/*stmtp*/, &bindp, _env._errh, idx+1,
const_cast<void*>(par.valuep), par.value_sz, par.dty,
const_cast<OCIInd*>(par.indp), 0/*alenp*/, 0/*rcodep*/,
0/*maxarr_len*/, 0/*curelep*/, OCI_DEFAULT);
oci_check_error(_env, res);
return bindp; // Implicitly allocated bind handles are freed automatically with the statement handle.
}


| OCIBind* OCIPL::SqlStatement::bind_input | ( | const tstring & | name, |
| BindInput | par, | ||
| OCIBind * | bindp = NULL |
||
| ) | [inline] |
Definition at line 3177 of file ocipl.h.
References OCIPL::BindInput::dty, OCIPL::BindInput::indp, OCIPL::oci_check_error(), OCIPL::BindInput::value_sz, and OCIPL::BindInput::valuep.
{
sword res = OCIBindByName(_handle/*stmtp*/, &bindp, _env._errh, (OraText*)name.c_str(), (sb4)name.length()*sizeof(TOraText),
const_cast<void*>(par.valuep), par.value_sz, par.dty,
const_cast<OCIInd*>(par.indp), 0/*alenp*/, 0/*rcodep*/,
0/*maxarr_len*/, 0/*curelep*/, OCI_DEFAULT);
oci_check_error(_env, res);
return bindp; // Implicitly allocated bind handles are freed automatically with the statement handle.
}

| OCIBind* OCIPL::SqlStatement::bind_output | ( | int | idx, |
| BindOutput | par, | ||
| OCIBind * | bindp = NULL |
||
| ) | [inline] |
Definition at line 3191 of file ocipl.h.
References OCIPL::BindOutput::dty, OCIPL::BindOutput::indp, OCIPL::oci_check_error(), OCIPL::BindOutput::value_sz, and OCIPL::BindOutput::valuep.
{
sword res = OCIBindByPos(_handle/*stmtp*/, &bindp, _env._errh, idx+1,
par.valuep, par.value_sz, par.dty,
par.indp, 0/*alenp*/, 0/*rcodep*/,
0/*maxarr_len*/, 0/*curelep*/, OCI_DEFAULT);
oci_check_error(_env, res);
return bindp; // Implicitly allocated bind handles are freed automatically with the statement handle.
}

| OCIBind* OCIPL::SqlStatement::bind_output | ( | const tstring & | name, |
| BindOutput | par, | ||
| OCIBind * | bindp = NULL |
||
| ) | [inline] |
Definition at line 3202 of file ocipl.h.
References OCIPL::BindOutput::dty, OCIPL::BindOutput::indp, OCIPL::oci_check_error(), OCIPL::BindOutput::value_sz, and OCIPL::BindOutput::valuep.
{
sword res = OCIBindByName(_handle/*stmtp*/, &bindp, _env._errh, (OraText*)name.c_str(), (sb4)name.length()*sizeof(TOraText),
par.valuep, par.value_sz, par.dty,
par.indp, 0/*alenp*/, 0/*rcodep*/,
0/*maxarr_len*/, 0/*curelep*/, OCI_DEFAULT);
oci_check_error(_env, res);
return bindp; // Implicitly allocated bind handles are freed automatically with the statement handle.
}

| OCIDefine * OCIPL::SqlStatement::bind_result | ( | int | idx, |
| DefinePar | par, | ||
| OCIDefine * | defnp = NULL |
||
| ) |
Definition at line 1092 of file ocipl.cpp.
References OCIPL::OciHandle< OCIStmt >::_env, OCIPL::OciEnv::_errh, OCIPL::OciHandle< OCIStmt >::_handle, _res, _result_buffers, _state, OCIPL::DefinePar::buffers, DEFINED, OCIPL::DefinePar::dty, EOF_DATA, EXECUTED, FETCHED, OCIPL::DefinePar::indp, OCIPL::oci_check_error(), OCIPL::DefinePar::value_sz, and OCIPL::DefinePar::valuep.
Referenced by OCIPL::SqlVariantArray::bind_result().
{
sword res = OCIDefineByPos(_handle/*stmtp*/, &defnp, _env._errh, idx+1,
par.valuep, par.value_sz, par.dty, par.indp,
(ub2*)0, (ub2*)0, OCI_DEFAULT);
oci_check_error(_env, res);
if (_state & DEFINED)
assert(_result_buffers==par.buffers); // check if all bind variables have the same buffer count
if (_state & EXECUTED) {
delete _res;
_res = NULL;
_state = (_state|DEFINED) & ~(FETCHED|EOF_DATA);
} else
_state |= DEFINED;
_result_buffers = par.buffers;
return defnp; // Implicitly allocated define handles are freed automatically with the statement handle.
}


| void OCIPL::SqlStatement::bind_result | ( | struct SqlRecord & | rec ) | [inline] |
Definition at line 3828 of file ocipl.h.
References OCIPL::SqlRecord::bind_result().
{rec.bind_result(*this);}

| void OCIPL::OciHandle< OCIStmt >::destroy | ( | ) | [inline, inherited] |
Definition at line 606 of file ocipl.h.
{
sword res = OCIHandleFree(_handle, super::get_type_id());
_handle = 0;
oci_check_error(_env, res);
}
| void OCIPL::SqlStatement::ensure_execute | ( | ) | [inline] |
| bool OCIPL::SqlStatement::eof | ( | ) | const [inline] |
| void OCIPL::SqlStatement::execute | ( | ) | [inline] |
Definition at line 3236 of file ocipl.h.
Referenced by fetch(), and print_results().
{
int rows = get_stmt_type()==OCI_STMT_SELECT? 0: 1;
execute(rows);
}

| void OCIPL::SqlStatement::execute | ( | ub4 | rows, |
| ub4 | mode = OCI_DEFAULT |
||
| ) |
Definition at line 1116 of file ocipl.cpp.
References _bulk_rows, _res, _state, DEFINED, execute_internal(), fetch(), and get_stmt_type().
{
// a SELECT statement without ready defined variables?
if (!(_state&DEFINED) && get_stmt_type()==OCI_STMT_SELECT) {
execute_internal(0, mode);
// define resultset variables
assert(!_res);
if (rows > 0) {
_res = new SqlResult(*this, rows);
fetch(rows);
} else {
_res = new SqlResult(*this, _bulk_rows);
}
} else
execute_internal(rows, mode);
}

| void OCIPL::SqlStatement::execute | ( | const tstring & | sql ) | [inline] |
Definition at line 3246 of file ocipl.h.
{
prepare(sql);
int rows = get_stmt_type()==OCI_STMT_SELECT? 0: 1;
execute(rows);
}
| void OCIPL::SqlStatement::execute | ( | const tstring & | sql, |
| const char * | file, | ||
| int | line | ||
| ) | [inline] |
Definition at line 3256 of file ocipl.h.
{
prepare(sql, file, line);
int rows = get_stmt_type()==OCI_STMT_SELECT? 0: 1;
execute(rows);
}
| void OCIPL::SqlStatement::execute | ( | const tstring & | sql, |
| ub4 | rows | ||
| ) | [inline] |
| void OCIPL::SqlStatement::execute | ( | const tstring & | sql, |
| const char * | file, | ||
| int | line, | ||
| ub4 | rows | ||
| ) | [inline] |
| void OCIPL::SqlStatement::execute_fetch | ( | ub4 | mode = OCI_DEFAULT ) |
Definition at line 1136 of file ocipl.cpp.
References _bulk_rows, _res, _result_buffers, _state, DEFINED, execute_internal(), fetch(), and get_stmt_type().
{
// A SELECT statement without ready defined variables?
if (!(_state&DEFINED) && get_stmt_type()==OCI_STMT_SELECT) {
execute_internal(0, mode);
// define resultset variables
assert(!_res);
_res = new SqlResult(*this, _bulk_rows);
fetch(_result_buffers);
} else
execute_internal(_result_buffers, mode);
}

| void OCIPL::SqlStatement::execute_fetch | ( | const tstring & | sql, |
| ub4 | lang = OCI_NTV_SYNTAX, |
||
| ub4 | mode = OCI_DEFAULT |
||
| ) | [inline] |
Definition at line 3293 of file ocipl.h.
{
prepare(sql, lang);
execute_fetch(mode);
}
| void OCIPL::SqlStatement::execute_fetch | ( | const tstring & | sql, |
| const char * | file, | ||
| int | line, | ||
| ub4 | lang = OCI_NTV_SYNTAX, |
||
| ub4 | mode = OCI_DEFAULT |
||
| ) | [inline] |
Definition at line 3301 of file ocipl.h.
{
prepare(sql, file, line, lang);
execute_fetch(mode);
}
| void OCIPL::SqlStatement::execute_internal | ( | ub4 | rows, |
| ub4 | mode | ||
| ) | [protected] |
Definition at line 1152 of file ocipl.cpp.
References _ctx, OCIPL::OciHandle< OCIStmt >::_env, OCIPL::OciEnv::_errh, OCIPL::OciHandle< OCIStmt >::_handle, _last_fetched_row, _last_row, _state, CODEPOS, EOF_DATA, EXECUTED, FETCHED, get_stmt_type(), OCIPL::oci_check_error(), OCIPL::OS_EXECUTE, row_count(), OCIPL::OciHandle< OCIStmt >::set_attribute(), STMT_ERROR, and OCIPL::throw_ocipl_exception().
Referenced by execute(), and execute_fetch().
{
int stmt_type = get_stmt_type();
LocalOciState state(_ctx, OS_EXECUTE, stmt_type);
if (rows==0 && stmt_type==OCI_STMT_SELECT) {
// Optimizing of TCP packets by transfering multiple datasets in one packet
try {
//set_attribute(OCI_ATTR_PREFETCH_MEMORY, 1500);
set_attribute(OCI_ATTR_PREFETCH_ROWS, 10);
} catch(std::exception&) {
// ignore exception of this optional performance tuning
}
}
// execute and fetch
sword res = OCIStmtExecute(_ctx, _handle, _env._errh, rows, 0/*rowoff*/,
(CONST OCISnapshot*)0, (OCISnapshot*)0, mode);
_last_row = 0;
_last_fetched_row = row_count();
if (res==OCI_NO_DATA && stmt_type>=OCI_STMT_SELECT && stmt_type<=OCI_STMT_INSERT) {
_state |= EOF_DATA;
// There are no additional rows pending to be fetched.
} else if (res == OCI_ERROR) {
_state = STMT_ERROR;
//throw OCI_EXCEPTION(_env._errh, *this, CODEPOS);
throw_ocipl_exception(OciException(_env._errh, *this, CODEPOS));
} else {
if (rows > 0)
_state |= EXECUTED|FETCHED;
else
_state = (_state|EXECUTED) & ~(FETCHED|EOF_DATA);
oci_check_error(_env, res);
// There may be more rows available to be fetched (for queries) or the DML statement succeeded.
}
}


| void OCIPL::SqlStatement::fetch | ( | ub4 | rows = (ub4)-1 ) |
Definition at line 1196 of file ocipl.cpp.
References _bulk_rows, _ctx, OCIPL::OciHandle< OCIStmt >::_env, OCIPL::OciEnv::_errh, OCIPL::OciHandle< OCIStmt >::_handle, _last_fetched_row, _last_row, _result_buffers, _state, DEFINED, EOF_DATA, execute(), EXECUTED, FETCHED, OCIPL::oci_check_error(), OCIPL::OS_FETCH, and row_count().
Referenced by execute(), execute_fetch(), and print_results().
{
if (!(_state & EXECUTED)) {
if (rows == (ub4)-1)
if (!(_state & DEFINED))
rows = _bulk_rows; // optimize using bulk fetch
else
rows = _result_buffers;
execute(rows);
} else {
if (rows == (ub4)-1)
rows = _result_buffers;
LocalOciState state(_ctx, OS_FETCH);
#if ORACLE_VERSION>=90
sword res = OCIStmtFetch2(_handle, _env._errh, rows, OCI_FETCH_NEXT, 0, OCI_DEFAULT);
#else
sword res = OCIStmtFetch(_handle, _env._errh, rows, OCI_FETCH_NEXT, OCI_DEFAULT);
#endif
_last_row = _last_fetched_row;
_last_fetched_row = row_count();
if (res != OCI_NO_DATA) { // more data available or did there occur an error?
_state |= FETCHED;
oci_check_error(_env, res);
// There may be more rows available to be fetched.
} else {
_state |= EOF_DATA;
// There are no additional rows pending to be fetched.
}
}
}


| ub4 OCIPL::SqlStatement::fetched_rows | ( | ) | const |
Definition at line 1063 of file ocipl.cpp.
References _last_fetched_row, and _last_row.
{
/*
if ORACLE_VERSION>=90
ub4 row_count;
ub4 size = sizeof(row_count);
sword res = OCIAttrGet(_handle, get_type_id(), &row_count, &size, OCI_ATTR_ROWS_FETCHED, _env._errh);
oci_check_error(_env, res);
return row_count;
else
*/
return _last_fetched_row - _last_row;
}
| int OCIPL::SqlStatement::first_bulk | ( | ) | [inline] |
Definition at line 3328 of file ocipl.h.
Referenced by OCIPL::ResultIterator::ResultIterator().
{
if (_state & EXECUTED)
fetch();
else
execute_fetch();
return fetched_rows();
}

| static ub4 OCIPL::OciHandleID< OCIStmt >::get_attr_id | ( | ) | [static, inherited] |
| void OCIPL::OciHandle< OCIStmt >::get_attribute | ( | dvoid * | attributep, |
| ub4 * | sizep, | ||
| ub4 | attrtype | ||
| ) | [inline, inherited] |
Definition at line 629 of file ocipl.h.
{
sword res = OCIAttrGet(_handle, super::get_type_id(), attributep, sizep, attrtype, _env._errh);
oci_check_error(_env, res);
}
| ub4 OCIPL::SqlStatement::get_column_count | ( | ) | const [inline] |
Definition at line 3349 of file ocipl.h.
References OCIPL::oci_check_error().
Referenced by OCIPL::SqlRecord::SqlRecord().
{
ub4 count;
ub4 size = sizeof(count);
sword res = OCIAttrGet(_handle, super::get_type_id(), &count, &size, OCI_ATTR_PARAM_COUNT, _env._errh);
oci_check_error(_env, res);
return count;
}


| void OCIPL::SqlStatement::get_column_type | ( | int | idx, |
| ColumnType & | info | ||
| ) | const |
Definition at line 1236 of file ocipl.cpp.
References OCIPL::OciHandle< OCIStmt >::_env, OCIPL::OciEnv::_errh, OCIPL::OciHandle< OCIStmt >::_handle, OCIPL::OciHandleID< OCIStmt >::get_type_id(), OCIPL::ColumnType::init(), and OCIPL::oci_check_error().
Referenced by OCIPL::SqlRecord::SqlRecord().
{
dvoid* parmdp;
sword res = OCIParamGet(_handle, get_type_id(), _env._errh, &parmdp, idx+1);
oci_check_error(_env, res);
info.init(_env._errh, parmdp);
res = OCIDescriptorFree(parmdp, OCI_DTYPE_PARAM);
oci_check_error(_env, res);
}


| const char* OCIPL::SqlStatement::get_last_file | ( | ) | const [inline] |
Definition at line 3135 of file ocipl.h.
Referenced by OCIPL::OciException::OciException().
{
return _last_file;
}

| int OCIPL::SqlStatement::get_last_line | ( | ) | const [inline] |
Definition at line 3140 of file ocipl.h.
Referenced by OCIPL::OciException::OciException().
{
return _last_line;
}

| const tstring& OCIPL::SqlStatement::get_last_sql | ( | ) | const [inline] |
Definition at line 3130 of file ocipl.h.
Referenced by OCIPL::OciException::OciException().
{
return _last_sql;
}

| const SqlResult& OCIPL::SqlStatement::get_result | ( | ) | [inline] |
| int OCIPL::SqlStatement::get_stmt_type | ( | ) | const |
Definition at line 1047 of file ocipl.cpp.
References OCIPL::OciHandle< OCIStmt >::_env, OCIPL::OciEnv::_errh, OCIPL::OciHandle< OCIStmt >::_handle, _stmt_type, OCIPL::OciHandleID< OCIStmt >::get_type_id(), and OCIPL::oci_check_error().
Referenced by execute(), execute_fetch(), and execute_internal().
{
if (_stmt_type == -1) {
ub2 stmt_type; // OCI_STMT_SELECT, OCI_STMT_UPDATE, ...
ub4 size = sizeof(stmt_type);
sword res = OCIAttrGet(_handle/*stmtp*/, get_type_id(), &stmt_type, &size, OCI_ATTR_STMT_TYPE, _env._errh);
oci_check_error(_env, res);
_stmt_type = stmt_type;
}
return _stmt_type;
}


| static ub4 OCIPL::OciHandleID< OCIStmt >::get_type_id | ( | ) | [static, inherited] |
Referenced by get_column_type(), get_stmt_type(), and row_count().

| bool OCIPL::SqlStatement::next | ( | ) | [inline] |
Definition at line 3315 of file ocipl.h.
{
if (!eof()) {
fetch(1);
return fetched_rows() > 0;
} else
return false;
}
| int OCIPL::SqlStatement::next_bulk | ( | ) | [inline] |
Definition at line 3338 of file ocipl.h.
{
if (!eof()) {
fetch();
return fetched_rows();
} else
return 0;
}
| OCIPL::OciHandle< OCIStmt >::operator HandleType * | ( | ) | [inline, inherited] |
| SqlResult* OCIPL::SqlStatement::operator-> | ( | ) | [inline] |
| void OCIPL::SqlStatement::prepare | ( | const tstring & | sql, |
| const char * | file, | ||
| int | line, | ||
| ub4 | lang = OCI_NTV_SYNTAX |
||
| ) | [virtual] |
Definition at line 962 of file ocipl.cpp.
References _ctx, OCIPL::OciHandle< OCIStmt >::_env, OCIPL::OciEnv::_errh, OCIPL::OciHandle< OCIStmt >::_handle, _last_file, _last_line, _last_sql, _res, _result_buffers, _state, _stmt_type, OCIPL::oci_check_error(), OCIPL::OS_PREPARE, and PREPARED.
{
delete _res;
_res = NULL;
_last_sql = sql;
_last_file = file;
_last_line = line;
LocalOciState state(_ctx, OS_PREPARE);
sword res = OCIStmtPrepare(_handle/*stmtp*/, _env._errh, (OraText*)sql.c_str(), (ub4)sql.length()*sizeof(TOraText), lang, OCI_DEFAULT);
oci_check_error(_env, res);
_state = PREPARED;
_stmt_type = -1;
_result_buffers = 0;
}

| void OCIPL::SqlStatement::prepare | ( | const tstring & | sql, |
| ub4 | lang = OCI_NTV_SYNTAX |
||
| ) |
| void OCIPL::SqlStatement::print_results | ( | tostream & | out, |
| bool | header = true |
||
| ) |
Definition at line 1319 of file ocipl.cpp.
References _res, _result_buffers, _state, execute(), EXECUTED, fetch(), FETCHED, OCIPL::ResultIterator::has_next(), OCIPL::SqlRecord::print_columns(), OCIPL::SqlRecord::print_values(), and TEXT.
{
if (!(_state & EXECUTED))
execute();
else if (!(_state & FETCHED))
fetch(_result_buffers);
if (header)
_res->print_columns(out);
int row_cnt = 0;
for(ResultIterator it(*this); it.has_next(); ++it) {
++row_cnt;
out << TEXT("row ") << row_cnt << TEXT(":\n");
_res->print_values(out, it);
out << TEXT("\n");
}
}

| int OCIPL::SqlStatement::result_buffers | ( | ) | const [inline] |
Definition at line 3158 of file ocipl.h.
{
return _result_buffers;
}
| ub4 OCIPL::SqlStatement::row_count | ( | ) | const |
Definition at line 1080 of file ocipl.cpp.
References OCIPL::OciHandle< OCIStmt >::_env, OCIPL::OciEnv::_errh, OCIPL::OciHandle< OCIStmt >::_handle, OCIPL::OciHandleID< OCIStmt >::get_type_id(), and OCIPL::oci_check_error().
Referenced by execute_internal(), and fetch().
{
ub4 row_count;
ub4 size = sizeof(row_count);
sword res = OCIAttrGet(_handle/*stmtp*/, get_type_id(), &row_count, &size, OCI_ATTR_ROW_COUNT, _env._errh);
oci_check_error(_env, res);
return row_count;
}


| void OCIPL::OciHandle< OCIStmt >::set_attribute | ( | ATTR & | attr ) | [inline, inherited] |
Definition at line 643 of file ocipl.h.
{
sword res = OCIAttrSet(_handle, super::get_type_id(), attr, 0, ATTR::get_attr_id(), _env._errh);
oci_check_error(_env, res);
}
| void OCIPL::OciHandle< OCIStmt >::set_attribute | ( | ub4 | attrtype, |
| ub4 | value | ||
| ) | [inline, inherited] |
Definition at line 622 of file ocipl.h.
{
sword res = OCIAttrSet(_handle, super::get_type_id(), (OraText*)&value, (ub4)sizeof(value), attrtype, _env._errh);
oci_check_error(_env, res);
}
| void OCIPL::OciHandle< OCIStmt >::set_attribute | ( | ub4 | attrtype, |
| const tstring & | str | ||
| ) | [inline, inherited] |
Definition at line 615 of file ocipl.h.
Referenced by execute_internal().
{
sword res = OCIAttrSet(_handle, super::get_type_id(), (TOraText*)str.c_str(), (ub4)str.length()*sizeof(TOraText), attrtype, _env._errh);
oci_check_error(_env, res);
}

| void OCIPL::OciHandle< OCIStmt >::set_attribute_handle | ( | ub4 | attrtype, |
| void * | handle | ||
| ) | [inline, inherited] |
Definition at line 636 of file ocipl.h.
{
sword res = OCIAttrSet(_handle, super::get_type_id(), handle, 0, attrtype, _env._errh);
oci_check_error(_env, res);
}
int OCIPL::SqlStatement::_bulk_rows [protected] |
Definition at line 3107 of file ocipl.h.
Referenced by execute(), execute_fetch(), and fetch().
OciContext& OCIPL::SqlStatement::_ctx [protected] |
Definition at line 3090 of file ocipl.h.
Referenced by execute_internal(), fetch(), and prepare().
OciEnv& OCIPL::OciHandle< OCIStmt >::_env [inherited] |
Definition at line 659 of file ocipl.h.
Referenced by bind_result(), execute_internal(), fetch(), get_column_type(), get_stmt_type(), prepare(), and row_count().
HandleType* OCIPL::OciHandle< OCIStmt >::_handle [protected, inherited] |
Definition at line 656 of file ocipl.h.
Referenced by bind_result(), execute_internal(), fetch(), get_column_type(), get_stmt_type(), prepare(), and row_count().
ub4 OCIPL::SqlStatement::_last_fetched_row [protected] |
Definition at line 3417 of file ocipl.h.
Referenced by execute_internal(), fetch(), and fetched_rows().
const char* OCIPL::SqlStatement::_last_file [protected] |
int OCIPL::SqlStatement::_last_line [protected] |
ub4 OCIPL::SqlStatement::_last_row [protected] |
Definition at line 3416 of file ocipl.h.
Referenced by execute_internal(), fetch(), and fetched_rows().
tstring OCIPL::SqlStatement::_last_sql [protected] |
struct SqlResult* OCIPL::SqlStatement::_res [protected] |
Definition at line 3103 of file ocipl.h.
Referenced by bind_result(), execute(), execute_fetch(), prepare(), print_results(), and ~SqlStatement().
int OCIPL::SqlStatement::_result_buffers [protected] |
Definition at line 3108 of file ocipl.h.
Referenced by bind_result(), execute_fetch(), fetch(), prepare(), and print_results().
int OCIPL::SqlStatement::_state [protected] |
Definition at line 3097 of file ocipl.h.
Referenced by bind_result(), execute(), execute_fetch(), execute_internal(), fetch(), prepare(), and print_results().
int OCIPL::SqlStatement::_stmt_type [mutable, protected] |
Definition at line 3105 of file ocipl.h.
Referenced by get_stmt_type(), and prepare().
1.7.2