Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes

OCIPL::SqlStatement Struct Reference

an OCI SQL statement More...

#include <ocipl.h>

Inheritance diagram for OCIPL::SqlStatement:
Inheritance graph
[legend]
Collaboration diagram for OCIPL::SqlStatement:
Collaboration graph
[legend]

List of all members.

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 tstringget_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 SqlResultget_result ()
SqlResultoperator-> ()
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

Detailed Description

an OCI SQL statement

Definition at line 3015 of file ocipl.h.


Member Typedef Documentation

typedef OCIStmt OCIPL::OciHandle< OCIStmt >::HandleType [inherited]

Definition at line 563 of file ocipl.h.

Reimplemented from OCIPL::OciHandle< OCIStmt >.

Definition at line 3017 of file ocipl.h.


Member Enumeration Documentation

Enumerator:
NO_HANDLE_ALLOC 

Definition at line 3073 of file ocipl.h.

enum OCIPL::SqlStatement::STATE [protected]
Enumerator:
UNINITIALIZED 
PREPARED 
DEFINED 
EXECUTED 
FETCHED 
EOF_DATA 
STMT_ERROR 

Definition at line 3092 of file ocipl.h.


Constructor & Destructor Documentation

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]

Definition at line 948 of file ocipl.cpp.

References _res.

{
    delete _res;
    _res = NULL;
}
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)
    {
    }

Member Function Documentation

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.
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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.
    }

Here is the call graph for this function:

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.
    }

Here is the call graph for this function:

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.
    }

Here is the call graph for this function:

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.
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);}

Here is the call graph for this function:

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]

Definition at line 3281 of file ocipl.h.

Referenced by OCIPL::SqlRecord::SqlRecord().

    {
        if (!(_state & EXECUTED))
            execute();
    }

Here is the caller graph for this function:

bool OCIPL::SqlStatement::eof (  ) const [inline]

Definition at line 3113 of file ocipl.h.

{return _state >= EOF_DATA;}
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);
    }

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

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]

Definition at line 3266 of file ocipl.h.

    {
        prepare(sql);

        execute(rows);
    }
void OCIPL::SqlStatement::execute ( const tstring sql,
const char *  file,
int  line,
ub4  rows 
) [inline]

Definition at line 3274 of file ocipl.h.

    {
        prepare(sql, file, line);

        execute(rows);
    }
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);
}

Here is the call graph for this function:

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.
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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.
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
    }

Here is the caller graph for this function:

int OCIPL::SqlStatement::get_last_line (  ) const [inline]

Definition at line 3140 of file ocipl.h.

Referenced by OCIPL::OciException::OciException().

    {
        return _last_line;
    }

Here is the caller graph for this function:

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;
    }

Here is the caller graph for this function:

const SqlResult& OCIPL::SqlStatement::get_result (  ) [inline]

Definition at line 3374 of file ocipl.h.

    {
        if (!(_state & EXECUTED))
            execute();

        return *_res;
    }
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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static ub4 OCIPL::OciHandleID< OCIStmt >::get_type_id (  ) [static, inherited]

Referenced by get_column_type(), get_stmt_type(), and row_count().

Here is the caller graph for this function:

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]

Definition at line 650 of file ocipl.h.

    {
        return _handle;
    }
SqlResult* OCIPL::SqlStatement::operator-> (  ) [inline]

Definition at line 3405 of file ocipl.h.

    {
        if (!_res)
            fetch();

        return _res;
    }
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;
}

Here is the call graph for this function:

void OCIPL::SqlStatement::prepare ( const tstring sql,
ub4  lang = OCI_NTV_SYNTAX 
)

Definition at line 956 of file ocipl.cpp.

{
    prepare(sql, NULL, -1, lang);
}
void OCIPL::SqlStatement::print_results ( const tstring sql,
tostream out,
bool  header = true 
) [inline]

Definition at line 3365 of file ocipl.h.

References CODEPOS.

    {
        execute(sql, CODEPOS);

        if (!eof())
            print_results(out, header);
    }
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");
    }
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);
    }

Here is the caller graph for this function:

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);
    }

Member Data Documentation

Definition at line 3107 of file ocipl.h.

Referenced by execute(), execute_fetch(), and fetch().

Definition at line 3090 of file ocipl.h.

Referenced by execute_internal(), fetch(), and prepare().

OciEnv& OCIPL::OciHandle< OCIStmt >::_env [inherited]
HandleType* OCIPL::OciHandle< OCIStmt >::_handle [protected, inherited]

Definition at line 3417 of file ocipl.h.

Referenced by execute_internal(), fetch(), and fetched_rows().

const char* OCIPL::SqlStatement::_last_file [protected]

Definition at line 3100 of file ocipl.h.

Referenced by prepare().

Definition at line 3101 of file ocipl.h.

Referenced by prepare().

Definition at line 3416 of file ocipl.h.

Referenced by execute_internal(), fetch(), and fetched_rows().

Definition at line 3099 of file ocipl.h.

Referenced by prepare().

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

Definition at line 3108 of file ocipl.h.

Referenced by bind_result(), execute_fetch(), fetch(), prepare(), and print_results().

int OCIPL::SqlStatement::_state [protected]
int OCIPL::SqlStatement::_stmt_type [mutable, protected]

Definition at line 3105 of file ocipl.h.

Referenced by get_stmt_type(), and prepare().


The documentation for this struct was generated from the following files: