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

OCIPL::SqlResult Struct Reference

class to retrieve query result values More...

#include <ocipl.h>

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

List of all members.

Public Member Functions

 SqlResult (SqlStatement &stmt, int rows=1)
bool is_null (int idx, int row) const
int is_null (const tstring &col_name, int row) const
bool is_not_null (int idx, int row) const
int is_not_null (const tstring &col_name, int row) const
int get_int (int idx, int row, int null=INT_NULL) const
int get_int (const tstring &col_name, int row, int null=INT_NULL) const
double get_double (int idx, int row, double null=0.) const
double get_double (const tstring &col_name, int row, double null=0.) const
SqlNumber get_number (int idx, int row) const
SqlNumber get_number (const tstring &col_name, int row) const
tstring get_string (int idx, int row) const
tstring get_string (const tstring &col_name, int row) const
OciDate get_oci_date (int idx, int row) const
OciDate get_oci_date (const tstring &col_name, int row) const
SqlDateTime get_sql_date (int idx, int row) const
SqlDateTime get_sql_date (const tstring &col_name, int row) const
size_t get_column_count () const
SqlVariantArrayget_column (int idx)
const SqlVariantArrayget_column (int idx) const
const SqlVariantArrayget_column (const tstring &col_name) const
ColumnTypeget_column_type (int idx)
const ColumnTypeget_column_type (int idx) const
const ColumnTypeget_column_type (const tstring &col_name) const
void bind_result (SqlStatement &stmt)
void alloc_column (size_t col_idx, const ColumnTypeInfo &type, int rows)
void print_columns (tostream &out)
void print_values (tostream &out, int row)

Public Attributes

OciEnv_env

Protected Types

typedef std::vector< DataColumnVector
typedef std::map< tstring, int > NameMap

Protected Member Functions

NameMap::const_iterator find_column (const tstring &col_name) const

Protected Attributes

ColumnVector _values
NameMap _name_map

Detailed Description

class to retrieve query result values

Definition at line 3594 of file ocipl.h.


Member Typedef Documentation

typedef std::vector<Data> OCIPL::SqlRecord::ColumnVector [protected, inherited]

Definition at line 3578 of file ocipl.h.

typedef std::map<tstring, int> OCIPL::SqlRecord::NameMap [protected, inherited]

Definition at line 3582 of file ocipl.h.


Constructor & Destructor Documentation

OCIPL::SqlResult::SqlResult ( SqlStatement stmt,
int  rows = 1 
) [inline]

Definition at line 3596 of file ocipl.h.

     :  SqlRecord(stmt, rows)
    {
        bind_result(stmt);
    }

Member Function Documentation

void OCIPL::SqlRecord::alloc_column ( size_t  col_idx,
const ColumnTypeInfo type,
int  rows 
) [inherited]

Definition at line 1368 of file ocipl.cpp.

References OCIPL::SqlRecord::Data::_pvar, and OCIPL::SqlRecord::_values.

{
    Data& data = _values[col_idx];

     // (re)allocate variant data buffers
    delete data._pvar;
    data._pvar = new SqlVariantArray(type, rows);
}
void OCIPL::SqlRecord::bind_result ( SqlStatement stmt ) [inherited]

Definition at line 1436 of file ocipl.cpp.

References OCIPL::SqlRecord::_values, and iterator.

Referenced by OCIPL::SqlStatement::bind_result().

{
    int idx = 0;

    for(ColumnVector::iterator it=_values.begin(); it!=_values.end(); ++it,++idx)
        it->_pvar->bind_result(stmt, idx);
}

Here is the caller graph for this function:

SqlRecord::NameMap::const_iterator OCIPL::SqlRecord::find_column ( const tstring col_name ) const [protected, inherited]

Definition at line 1413 of file ocipl.cpp.

References OCIPL::SqlRecord::_name_map, _tcsupr_s, OCIPL::SqlRecord::_values, and TCHAR.

Referenced by OCIPL::SqlRecord::get_column(), and OCIPL::SqlRecord::get_column_type().

{
    tstring upper_name;

     // initialize column name map
    if (_name_map.empty()) {
        int idx = 0;

        for(ColumnVector::const_iterator it=_values.begin(); it!=_values.end(); ++it,++idx) {
            upper_name = it->_type._name.c_str();
            _tcsupr_s((TCHAR*)upper_name.data(), upper_name.length()+1);

            _name_map[upper_name] = idx;
        }
    }

    upper_name = col_name;
    _tcsupr_s((TCHAR*)upper_name.data(), upper_name.length()+1);

    return _name_map.find(upper_name);
}

Here is the caller graph for this function:

const SqlVariantArray& OCIPL::SqlRecord::get_column ( int  idx ) const [inline, inherited]

Definition at line 3547 of file ocipl.h.

        {return *_values[idx]._pvar;}
const SqlVariantArray & OCIPL::SqlRecord::get_column ( const tstring col_name ) const [inherited]

Definition at line 1395 of file ocipl.cpp.

References OCIPL::SqlRecord::_name_map, OCIPL::SqlRecord::_values, OCIPL::SqlRecord::find_column(), and THROW_OCI_EXCEPTION.

{
/*
    for(ColumnVector::const_iterator it=_values.begin(); it!=_values.end(); ++it)
        if (!stricmp(it->_type._name.c_str(), col_name.c_str()))
            return *it->_pvar;
*/
    NameMap::const_iterator found = find_column(col_name);

    if (found != _name_map.end()) {
        int idx = found->second;
        return *_values[idx]._pvar;
    } else {
        THROW_OCI_EXCEPTION("column not found");
//      return SqlVariantArray::s_empty;
    }
}

Here is the call graph for this function:

SqlVariantArray& OCIPL::SqlRecord::get_column ( int  idx ) [inline, inherited]

Definition at line 3542 of file ocipl.h.

        {return *_values[idx]._pvar;}
size_t OCIPL::SqlRecord::get_column_count (  ) const [inline, inherited]

Definition at line 3539 of file ocipl.h.

        {return _values.size();}
const ColumnType & OCIPL::SqlRecord::get_column_type ( const tstring col_name ) const [inherited]

Definition at line 1377 of file ocipl.cpp.

References OCIPL::SqlRecord::_name_map, OCIPL::SqlRecord::_values, OCIPL::SqlRecord::find_column(), and THROW_OCI_EXCEPTION.

{
/*
    for(ColumnVector::const_iterator it=_values.begin(); it!=_values.end(); ++it)
        if (!stricmp(it->_type._name.c_str(), col_name.c_str()))
            return it->_type;
*/
    NameMap::const_iterator found = find_column(col_name);

    if (found != _name_map.end()) {
        int idx = found->second;
        return _values[idx]._type;
    } else {
        THROW_OCI_EXCEPTION("column not found");
//      return ColumnType::s_empty;
    }
}

Here is the call graph for this function:

ColumnType& OCIPL::SqlRecord::get_column_type ( int  idx ) [inline, inherited]

Definition at line 3544 of file ocipl.h.

        {return _values[idx]._type;}
const ColumnType& OCIPL::SqlRecord::get_column_type ( int  idx ) const [inline, inherited]

Definition at line 3549 of file ocipl.h.

        {return _values[idx]._type;}
double OCIPL::SqlResult::get_double ( int  idx,
int  row,
double  null = 0. 
) const [inline]

Definition at line 3640 of file ocipl.h.

    {
        return get_column(idx).number(row, _env._errh).get_double(_env._errh, null);
    }
double OCIPL::SqlResult::get_double ( const tstring col_name,
int  row,
double  null = 0. 
) const [inline]

Definition at line 3644 of file ocipl.h.

    {
        return get_column(col_name).number(row, _env._errh).get_double(_env._errh, null);
    }
int OCIPL::SqlResult::get_int ( int  idx,
int  row,
int  null = INT_NULL 
) const [inline]

Definition at line 3620 of file ocipl.h.

    {
        return get_column(idx).number(row, _env._errh).get_int(_env._errh, null);
    }
int OCIPL::SqlResult::get_int ( const tstring col_name,
int  row,
int  null = INT_NULL 
) const [inline]

Definition at line 3624 of file ocipl.h.

    {
        return get_column(col_name).number(row, _env._errh).get_int(_env._errh, null);
    }
SqlNumber OCIPL::SqlResult::get_number ( int  idx,
int  row 
) const [inline]

Definition at line 3649 of file ocipl.h.

    {
        return get_column(idx).number(row, _env._errh);
    }
SqlNumber OCIPL::SqlResult::get_number ( const tstring col_name,
int  row 
) const [inline]

Definition at line 3653 of file ocipl.h.

    {
        return get_column(col_name).number(row, _env._errh);
    }
OciDate OCIPL::SqlResult::get_oci_date ( int  idx,
int  row 
) const [inline]

Definition at line 3667 of file ocipl.h.

    {
        return get_column(idx).oci_date(row, _env._errh);
    }
OciDate OCIPL::SqlResult::get_oci_date ( const tstring col_name,
int  row 
) const [inline]

Definition at line 3671 of file ocipl.h.

    {
        return get_column(col_name).oci_date(row, _env._errh);
    }
SqlDateTime OCIPL::SqlResult::get_sql_date ( const tstring col_name,
int  row 
) const [inline]

Definition at line 3680 of file ocipl.h.

    {
        return get_column(col_name).sql_date(row, _env._errh);
    }
SqlDateTime OCIPL::SqlResult::get_sql_date ( int  idx,
int  row 
) const [inline]

Definition at line 3676 of file ocipl.h.

    {
        return get_column(idx).sql_date(row, _env._errh);
    }
tstring OCIPL::SqlResult::get_string ( int  idx,
int  row 
) const [inline]

Definition at line 3658 of file ocipl.h.

References OCIPL::SqlNumber::str().

    {
        return get_column(idx).str(row, _env._errh);
    }

Here is the call graph for this function:

tstring OCIPL::SqlResult::get_string ( const tstring col_name,
int  row 
) const [inline]

Definition at line 3662 of file ocipl.h.

    {
        return get_column(col_name).str(row, _env._errh);
    }
bool OCIPL::SqlResult::is_not_null ( int  idx,
int  row 
) const [inline]

Definition at line 3611 of file ocipl.h.

    {
        return get_column(idx).is_not_null(row);
    }
int OCIPL::SqlResult::is_not_null ( const tstring col_name,
int  row 
) const [inline]

Definition at line 3615 of file ocipl.h.

    {
        return get_column(col_name).is_not_null(row);
    }
int OCIPL::SqlResult::is_null ( const tstring col_name,
int  row 
) const [inline]

Definition at line 3606 of file ocipl.h.

    {
        return get_column(col_name).is_null(row);
    }
bool OCIPL::SqlResult::is_null ( int  idx,
int  row 
) const [inline]

Definition at line 3602 of file ocipl.h.

    {
        return get_column(idx).is_null(row);
    }
void OCIPL::SqlRecord::print_columns ( tostream out ) [inherited]

Definition at line 1444 of file ocipl.cpp.

References OCIPL::SqlRecord::_values, and TEXT.

Referenced by OCIPL::SqlStatement::print_results().

{
    for(ColumnVector::const_iterator it=_values.begin(); it!=_values.end(); ++it)
        out << it->_type._name << TEXT(": ") << it->_type.get_type_str() << TEXT("\n");

    out << TEXT("\n");
}

Here is the caller graph for this function:

void OCIPL::SqlRecord::print_values ( tostream out,
int  row 
) [inherited]

Definition at line 1452 of file ocipl.cpp.

References OCIPL::SqlRecord::_env, OCIPL::OciEnv::_errh, OCIPL::SqlRecord::_values, and TEXT.

Referenced by OCIPL::SqlStatement::print_results().

{
    ColumnVector::const_iterator it_type = _values.begin();

    for(ColumnVector::const_iterator it=_values.begin(); it!=_values.end(); ++it,++it_type)
        out << it->_type._name << TEXT("=") << it->_pvar->str(row, _env._errh) << TEXT("\n");
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 3588 of file ocipl.h.

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

NameMap OCIPL::SqlRecord::_name_map [mutable, protected, inherited]
ColumnVector OCIPL::SqlRecord::_values [protected, inherited]

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