[Ocipl-commits] SF.net SVN: ocipl: [42] trunk/ocipl
Brought to you by:
martinfuchs
|
From: <mar...@us...> - 2008-02-09 10:16:35
|
Revision: 42
http://ocipl.svn.sourceforge.net/ocipl/?rev=42&view=rev
Author: martinfuchs
Date: 2008-02-09 02:16:38 -0800 (Sat, 09 Feb 2008)
Log Message:
-----------
OCIPL Version 1.4:
- struct ResultIterator as loop iterator utilizing bulk mode fetching
- use INT_NULL as default for get_int() functions
- added break statements in throw_oci_exception()
Modified Paths:
--------------
trunk/ocipl/ocipl.cpp
trunk/ocipl/ocipl.h
Modified: trunk/ocipl/ocipl.cpp
===================================================================
--- trunk/ocipl/ocipl.cpp 2008-02-09 10:13:36 UTC (rev 41)
+++ trunk/ocipl/ocipl.cpp 2008-02-09 10:16:38 UTC (rev 42)
@@ -2,9 +2,9 @@
//
// ocipl.cpp
//
- // Copyright (c) 2003, 2004, 2005, 2006, 2007 Martin Fuchs <mar...@gm...>
+ // Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 Martin Fuchs <mar...@gm...>
//
- // OCIPL Version 1.3
+ // OCIPL Version 1.4
//
/// \file ocipl.cpp
@@ -65,9 +65,11 @@
switch(res) {
case OCI_ERROR:
THROW_OCI_EXCEPTION(errh);
+ break;
case OCI_INVALID_HANDLE:
THROW_OCI_EXCEPTION("invalid handle");
+ break;
//@todo handle other error states
Modified: trunk/ocipl/ocipl.h
===================================================================
--- trunk/ocipl/ocipl.h 2008-02-09 10:13:36 UTC (rev 41)
+++ trunk/ocipl/ocipl.h 2008-02-09 10:16:38 UTC (rev 42)
@@ -2,10 +2,10 @@
//
// ocipl.h
//
- // Copyright (c) 2003, 2004, 2005, 2006, 2007 Martin Fuchs <mar...@gm...>
- //
- // OCIPL Version 1.3
+ // Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 Martin Fuchs <mar...@gm...>
//
+ // OCIPL Version 1.4
+ //
/// \file ocipl.h
/// OCIPL header file
@@ -1383,7 +1383,7 @@
extern tstring number_to_str(const oraclenumber& val, OCIError* errh, const TCHAR* fmt, const TCHAR* nls_fmt);
#ifdef _MSC_VER
-extern __int64 number_to_int64(const oraclenumber& val, OCIError* errh, int null=0);
+extern __int64 number_to_int64(const oraclenumber& val, OCIError* errh, int null=INT_NULL);
#endif
@@ -1435,7 +1435,7 @@
operator OCINumber*() {return (OCINumber*)&_val;}
operator const OCINumber*() const {return (OCINumber*)&_val;}
- int get_int(OCIError* errh, int null=0) const
+ int get_int(OCIError* errh, int null=INT_NULL) const
{
if (is_null())
return null;
@@ -1444,7 +1444,7 @@
}
#ifdef _MSC_VER
- __int64 get_int64(OCIError* errh, int null=0) const
+ __int64 get_int64(OCIError* errh, int null=INT_NULL) const
{
if (is_null())
return null;
@@ -1493,7 +1493,7 @@
return tstring();
}
- int get_int(int row, OCIError* errh, int null=0) const
+ int get_int(int row, OCIError* errh, int null=INT_NULL) const
{
if (is_not_null(row))
return number_to_int(_pvalues[row], errh);
@@ -1502,7 +1502,7 @@
}
#ifdef _MSC_VER
- __int64 get_int64(int row, OCIError* errh, int null=0) const
+ __int64 get_int64(int row, OCIError* errh, int null=INT_NULL) const
{
if (is_not_null(row))
return number_to_int64(_pvalues[row], errh, null);
@@ -2874,6 +2874,15 @@
return get_column(col_name).number(row, _env._errh).get_double(_env._errh);
}
+ SqlNumber get_number(int idx, int row) const
+ {
+ return get_column(idx).number(row, _env._errh);
+ }
+ SqlNumber get_number(const tstring& col_name, int row) const
+ {
+ return get_column(col_name).number(row, _env._errh);
+ }
+
tstring get_string(int idx, int row) const
{
return get_column(idx).str(row, _env._errh);
@@ -2905,6 +2914,147 @@
};
+ /// iterator utilizing bulk mode fetching
+
+struct ResultIterator
+{
+ typedef ResultIterator myType;
+
+ ResultIterator(SqlStatement& stmt)
+ : _stmt(stmt),
+ _row_idx(0),
+ _row_nr(1)
+ {
+ _fetched = stmt.first_bulk();
+ }
+
+ int get_row_idx() const
+ {
+ return _row_idx;
+ }
+
+ operator int() const
+ {
+ return _row_idx;
+ }
+
+ int get_row_nr() const
+ {
+ return _row_nr;
+ }
+
+ bool has_next()
+ {
+ return _row_idx < _fetched;
+ }
+
+ myType& operator++()
+ {
+ if (++_row_idx >= _fetched) {
+ _fetched = _stmt.next_bulk();
+
+ if (_fetched) {
+ _row_idx = 0;
+ ++_row_nr;
+ }
+ } else
+ ++_row_nr;
+
+ return *this;
+ }
+
+ bool is_null(int idx) const
+ {
+ return _stmt->is_null(idx, _row_idx);
+ }
+ int is_null(const tstring& col_name) const
+ {
+ return _stmt->is_null(col_name, _row_idx);
+ }
+
+ bool is_not_null(int idx) const
+ {
+ return _stmt->is_not_null(idx, _row_idx);
+ }
+ int is_not_null(const tstring& col_name) const
+ {
+ return _stmt->is_not_null(col_name, _row_idx);
+ }
+
+ int get_int(int idx) const
+ {
+ return _stmt->get_int(idx, _row_idx);
+ }
+ int get_int(const tstring& col_name) const
+ {
+ return _stmt->get_int(col_name, _row_idx);
+ }
+
+#ifdef _MSC_VER
+ __int64 get_int64(int idx) const
+ {
+ return _stmt->get_int64(idx, _row_idx);
+ }
+ __int64 get_int64(const tstring& col_name) const
+ {
+ return _stmt->get_int64(col_name, _row_idx);
+ }
+#endif
+
+ double get_double(int idx) const
+ {
+ return _stmt->get_double(idx, _row_idx);
+ }
+ double get_double(const tstring& col_name) const
+ {
+ return _stmt->get_double(col_name, _row_idx);
+ }
+
+ SqlNumber get_number(int idx) const
+ {
+ return _stmt->get_number(idx, _row_idx);
+ }
+ SqlNumber get_number(const tstring& col_name) const
+ {
+ return _stmt->get_number(col_name, _row_idx);
+ }
+
+ tstring get_string(int idx) const
+ {
+ return _stmt->get_string(idx, _row_idx);
+ }
+ tstring get_string(const tstring& col_name) const
+ {
+ return _stmt->get_string(col_name, _row_idx);
+ }
+
+ OciDate get_oci_date(int idx) const
+ {
+ return _stmt->get_oci_date(idx, _row_idx);
+ }
+ OciDate get_oci_date(const tstring& col_name) const
+ {
+ return _stmt->get_oci_date(col_name, _row_idx);
+ }
+
+ SqlDateTime get_sql_date(int idx) const
+ {
+ return _stmt->get_sql_date(idx, _row_idx);
+ }
+ SqlDateTime get_sql_date(const tstring& col_name) const
+ {
+ return _stmt->get_sql_date(col_name, _row_idx);
+ }
+
+protected:
+ SqlStatement& _stmt;
+
+ int _fetched;
+ int _row_idx;
+ int _row_nr;
+};
+
+
inline void SqlStatement::bind_result(SqlRecord& rec)
{rec.bind_result(*this);}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|