Date: Thursday, March 9, 2006 @ 16:01:30
  Author: marc
    Path: /cvsroot/carob/odbsequoia/src

Modified: stmt.cpp (1.18 -> 1.19) stmt.hpp (1.13 -> 1.14)

New method bool in_state_cursor()


----------+
 stmt.cpp |   15 +++++++--------
 stmt.hpp |   12 ++++++++++--
 2 files changed, 17 insertions(+), 10 deletions(-)


Index: odbsequoia/src/stmt.cpp
diff -u odbsequoia/src/stmt.cpp:1.18 odbsequoia/src/stmt.cpp:1.19
--- odbsequoia/src/stmt.cpp:1.18        Thu Mar  9 15:02:45 2006
+++ odbsequoia/src/stmt.cpp     Thu Mar  9 16:01:30 2006
@@ -79,9 +79,8 @@
 ODBCStatement::row_count(SQLHSTMT shdle, SQLLEN * rowcount)
 {
     // DM will probably catch this before us
-    if (S5 != state
-        && S4 != state)
-        throw ODBSeqException(L"HY010", L"invalid state for SQLRowCount, 
neither S4 nor S5");
+    if (! in_state_cursor())
+        throw ODBSeqException(L"HY010", L"not in cursor state for 
SQLRowCount");
 
     *rowcount = carob_stmt->getUpdateCount();
 
@@ -135,16 +134,16 @@
 SQLRETURN
 ODBCStatement::fetch()
 {
-    // FIXME: work in progress, not even half-implemented
+    // TODO work in progress
 
+    // DM will probably catch this before us
+    if (! in_state_cursor())
+        throw ODBSeqException(L"HY010",
+                              L"not in cursor state for SQLFetch()");
     if (this->state == S4)
         throw ODBSeqException(L"24000",
                               L"No ResultSet available");
 
-    if (this->state != S5 && this->state != S6)
-        throw ODBSeqException(L"HY010",
-                              L"Invalid state, no current ResultSet"
-                              " (TODO: print current state)");
 
     if (! carob_stmt->getResultSet()->next())
         return SQL_NO_DATA;
Index: odbsequoia/src/stmt.hpp
diff -u odbsequoia/src/stmt.hpp:1.13 odbsequoia/src/stmt.hpp:1.14
--- odbsequoia/src/stmt.hpp:1.13        Thu Mar  9 11:36:57 2006
+++ odbsequoia/src/stmt.hpp     Thu Mar  9 16:01:30 2006
@@ -33,7 +33,10 @@
 
 namespace ODBSeqNS {
 
-    enum stmt_state_t { S0, S1, S4, S5, S6 };
+    enum stmt_state_t { S0, S1, S4, S5, S6, S7 };
+    // - S1 when carob_stmt is allocated
+    // - S7 is used only when supporting ODBC version 2
+    //   SQLExtendedFetch(), which is deprecated in ODBC 3
 
 class ODBCStatement : public ODBCItem
 {
@@ -41,7 +44,7 @@
     CarobNS::Statement* carob_stmt;
     /** State according to "Statement Transitions" in the ODBC
      *  reference (as far as possible). */
-    stmt_state_t state;  // S1 when carob_stmt is allocated
+    stmt_state_t state;
 
     ODBCStatement(const ODBCConnection& creator) : 
         ODBCItem(creator),
@@ -91,6 +94,11 @@
         const;
 
 private:
+
+    bool
+    in_state_cursor() const
+    { return (state == S4 || state == S5 || state == S7); }
+
     ODBCImplParamDesc IRD;
     ODBCImplRowDesc IPD;
     ODBCAppDesc implicit_ARD;

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to