Date: Monday, November 28, 2005 @ 13:52:16
  Author: gilles
    Path: /cvsroot/carob/carob

Modified: include/Connection.hpp (1.25 -> 1.26) src/Connection.cpp (1.27
          -> 1.28)

Added tryFetchNext() function


------------------------+
 include/Connection.hpp |   14 +++++++++++++-
 src/Connection.cpp     |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)


Index: carob/include/Connection.hpp
diff -u carob/include/Connection.hpp:1.25 carob/include/Connection.hpp:1.26
--- carob/include/Connection.hpp:1.25   Thu Nov 24 15:55:08 2005
+++ carob/include/Connection.hpp        Mon Nov 28 13:52:16 2005
@@ -56,7 +56,7 @@
 //#define RollbackToSavepoint                     26
 #define Close                                   30
 #define Reset                                   31
-//#define FetchNextResultSetRows                  32
+#define FetchNextResultSetRows                  32
 #define CloseRemoteResultSet                    33
 //#define RestoreConnectionState                  34
 #define SetAutoCommit                           35
@@ -236,6 +236,18 @@
    */
   void              setReadOnly(bool readOnlyPrm) throw (SocketIOException,
                         DriverException, UnexpectedException);
+  /**
+   * Sends "FetchNextResultSetRows" command to controller. Throws a
+   * ControllerException if controller returns an error; else returns void and
+   * lets the caller receive its new rows by itself.
+   * 
+   * @param cursorName name of the ResultSet cursor
+   * @param fetchSize number of rows to fetch
+   * @throws ControllerException if an error occurs
+   */
+  void              tryFetchNext(const wstring& cursorName, int fetchSize)
+                        throw (ControllerException, SocketIOException,
+                        ProtocolException, UnexpectedException);
 
 protected:
   /** 
Index: carob/src/Connection.cpp
diff -u carob/src/Connection.cpp:1.27 carob/src/Connection.cpp:1.28
--- carob/src/Connection.cpp:1.27       Thu Nov 24 15:55:08 2005
+++ carob/src/Connection.cpp    Mon Nov 28 13:52:16 2005
@@ -621,6 +621,44 @@
   request.sendToStream(*driverSocketPtr, controllerNeedsSqlSkeleton);
 
 }
+void Connection::tryFetchNext(const wstring& cursorName, int fetchSize)
+    throw (SocketIOException, ControllerException, ProtocolException,
+    UnexpectedException)
+{   
+  wstring fctName(L"Connection::tryFetchNext");
+
+  connectionCS.Enter();
+
+  checkIfConnected();
+
+  try
+  {
+    sendCommand(*driverSocketPtr, FetchNextResultSetRows);
+    *driverSocketPtr<<cursorName;
+    *driverSocketPtr<<fetchSize;
+    if (isDebugEnabled())
+    {
+      logDebug(fctName, L"Fetching next " + toWString(fetchSize) + L" from "
+          + cursorName);
+    }
+    TypeTag tag(*driverSocketPtr);
+
+    if (tag == TT_EXCEPTION)
+      receiveException();
+
+    if (tag == TT_NOT_EXCEPTION)
+      throw ProtocolException(L"Protocol exception while trying fetchNext");
+
+    // success, now we can let the DriverResultSet caller receive its data.
+
+  }
+  catch (...)
+  {
+    connectionCS.Leave();
+    throw;
+  }
+  connectionCS.Leave();
+}
 
 
 void Connection::closeRemoteResultSet(wstring cursorName)

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

Reply via email to