class to retrieve query result values More...
#include <ocipl.h>
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 |
SqlVariantArray & | get_column (int idx) |
const SqlVariantArray & | get_column (int idx) const |
const SqlVariantArray & | get_column (const tstring &col_name) const |
ColumnType & | get_column_type (int idx) |
const ColumnType & | get_column_type (int idx) const |
const ColumnType & | get_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< Data > | ColumnVector |
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 |
class to retrieve query result values
Definition at line 3594 of file ocipl.h.
typedef std::vector<Data> OCIPL::SqlRecord::ColumnVector [protected, inherited] |
typedef std::map<tstring, int> OCIPL::SqlRecord::NameMap [protected, inherited] |
OCIPL::SqlResult::SqlResult | ( | SqlStatement & | stmt, |
int | rows = 1 |
||
) | [inline] |
Definition at line 3596 of file ocipl.h.
: SqlRecord(stmt, rows) { bind_result(stmt); }
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); }
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); }
const SqlVariantArray& OCIPL::SqlRecord::get_column | ( | int | idx ) | const [inline, inherited] |
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; } }
SqlVariantArray& OCIPL::SqlRecord::get_column | ( | int | idx ) | [inline, inherited] |
size_t OCIPL::SqlRecord::get_column_count | ( | ) | const [inline, inherited] |
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; } }
ColumnType& OCIPL::SqlRecord::get_column_type | ( | int | idx ) | [inline, inherited] |
const ColumnType& OCIPL::SqlRecord::get_column_type | ( | int | idx ) | const [inline, inherited] |
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); }
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); }
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); }
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"); }
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"); }
OciEnv& OCIPL::SqlRecord::_env [inherited] |
Definition at line 3588 of file ocipl.h.
Referenced by OCIPL::SqlRecord::print_values().
NameMap OCIPL::SqlRecord::_name_map [mutable, protected, inherited] |
Definition at line 3583 of file ocipl.h.
Referenced by OCIPL::SqlRecord::find_column(), OCIPL::SqlRecord::get_column(), and OCIPL::SqlRecord::get_column_type().
ColumnVector OCIPL::SqlRecord::_values [protected, inherited] |
Definition at line 3580 of file ocipl.h.
Referenced by OCIPL::SqlRecord::alloc_column(), OCIPL::SqlRecord::bind_result(), OCIPL::SqlRecord::find_column(), OCIPL::SqlRecord::get_column(), OCIPL::SqlRecord::get_column_type(), OCIPL::SqlRecord::print_columns(), OCIPL::SqlRecord::print_values(), OCIPL::SqlRecord::SqlRecord(), and OCIPL::SqlRecord::~SqlRecord().