Date: Thursday, January 5, 2006 @ 16:18:33
  Author: marc
    Path: /cvsroot/carob/odbsequoia/src

Modified: stmt.cpp (1.1 -> 1.2)

Added ODBC state (enum). Implemented SQLRowCount.


----------+
 stmt.cpp |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)


Index: odbsequoia/src/stmt.cpp
diff -u odbsequoia/src/stmt.cpp:1.1 odbsequoia/src/stmt.cpp:1.2
--- odbsequoia/src/stmt.cpp:1.1 Thu Dec 22 19:55:20 2005
+++ odbsequoia/src/stmt.cpp     Thu Jan  5 16:18:33 2006
@@ -27,6 +27,7 @@
 
 #include "connect.hpp"
 
+enum stmt_state_t { S0, S1, S4, S5 };
 
 namespace ODBSeqNS {
 
@@ -34,6 +35,10 @@
     // a ref here instead?
     ODBCConnection *conn;
     CarobNS::Statement* carob_stmt;
+    stmt_state_t state;  // state according to "Statement Transitions"
+                         // in the ODBC reference (as far as
+                         // possible).
+    odbsequoia_stmt_() { state = S0; };
 } ODBCStatement;
 
 }
@@ -47,13 +52,16 @@
                SQLWCHAR *StatementText, SQLINTEGER TextLength)
 {
     SQLRETURN  ret = SQL_SUCCESS;
-    ODBCStatement * stmt = (ODBCStatement *)StatementHandle;
-
-
+    ODBCStatement * self_p = (ODBCStatement *)StatementHandle;
+    
     try
     {    
         std::wstring wstext = fromSQLW(StatementText, TextLength);
-        stmt->carob_stmt->executeUpdate(wstext); 
+        bool resultIsSet = self_p->carob_stmt->execute(wstext);
+        if (resultIsSet)
+            self_p->state = S5;
+        else
+            self_p->state = S4;
     }
     catch (const CarobException& ce)
     {
@@ -62,11 +70,30 @@
     return ret;
 }
 
+SQLRETURN
+SQLRowCount(SQLHSTMT shdle, SQLLEN * rowcount)
+{
+    ODBCStatement * self_p = (ODBCStatement *)shdle;
+
+    if (S5 != self_p->state
+        && S4 != self_p->state)
+        return SQL_ERROR; // TODO: HY010
+
+    *rowcount = self_p->carob_stmt->getUpdateCount();
+
+//    if (-1 == *rowcount) // driver-defined in S5. We could return RS.length.
+//        *rowcount = ? ;
+
+    return SQL_SUCCESS;
+}
+
+
 SQLRETURN ODBSeqNS::alloc_statement(SQLHANDLE InputHandle, SQLHANDLE * 
OutputHandle)
 {
     ODBCStatement *newstmt = new ODBCStatement;
     newstmt->conn = (ODBCConnection *) InputHandle;
     newstmt->carob_stmt = newstmt->conn->carob_conn->createStatement();
+    newstmt->state = S1;
     *OutputHandle = newstmt;
     return SQL_SUCCESS;
 }

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

Reply via email to