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

Modified: stmt.cpp (1.20 -> 1.21) stmt.hpp (1.15 -> 1.16)

Implemented SQLNumResultCols()


----------+
 stmt.cpp |   36 ++++++++++++++++++++++++++++++++++++
 stmt.hpp |    7 +++++--
 2 files changed, 41 insertions(+), 2 deletions(-)


Index: odbsequoia/src/stmt.cpp
diff -u odbsequoia/src/stmt.cpp:1.20 odbsequoia/src/stmt.cpp:1.21
--- odbsequoia/src/stmt.cpp:1.20        Thu Mar  9 16:11:49 2006
+++ odbsequoia/src/stmt.cpp     Thu Mar  9 18:56:30 2006
@@ -19,6 +19,7 @@
  * Contributor(s): 
  */
 
+#include "ResultSetMetaData.hpp"
 #include "Statement.hpp"
 
 #include "util.hpp"
@@ -155,6 +156,41 @@
     
 }
 
+
+SQLRETURN
+SQLNumResultCols(SQLHSTMT StatementHandle,
+                 SQLSMALLINT * ColumnCountPtr)
+{
+    ODBCStatement * self_p = objectify(StatementHandle);
+    self_p->clear_diags();
+
+    _PROTECT_SQLRETURN(self_p, num_result_cols(ColumnCountPtr));
+}
+
+SQLRETURN
+ODBCStatement::num_result_cols(SQLSMALLINT * num_cols)
+{
+
+    if (S2 == state || S4 == state) // typically: write statements
+    {
+        * num_cols = 0;
+        return SQL_SUCCESS;
+    }
+
+    if (in_state_cursor() || S3 == state)
+    {
+        * num_cols = carob_stmt->getMetaData()->getColumnCount();
+        return SQL_SUCCESS;
+    }
+
+    // DM will probably catch most of these before us
+    throw ODBSeqException(L"HY010",
+                          L"Invalid state");
+
+    return SQL_SUCCESS;
+}
+
+
 SQLRETURN
 ODBCStatement::get_header_diag_fieldw(SQLSMALLINT DiagIdentifier,
                                       SQLPOINTER DiagInfoPtr,
Index: odbsequoia/src/stmt.hpp
diff -u odbsequoia/src/stmt.hpp:1.15 odbsequoia/src/stmt.hpp:1.16
--- odbsequoia/src/stmt.hpp:1.15        Thu Mar  9 16:11:49 2006
+++ odbsequoia/src/stmt.hpp     Thu Mar  9 18:56:30 2006
@@ -33,8 +33,8 @@
 
 namespace ODBSeqNS {
 
-    enum stmt_state_t { S0, S1, S4, S5, S6, S7 };
-    // - S1 when carob_stmt is allocated
+    enum stmt_state_t { S0, S1, S2, S3, S4, S5, S6, S7 };
+    // - S0 -> S1 when carob_stmt field is allocated
     // - S7 is used only when supporting ODBC version 2
     //   SQLExtendedFetch(), which is deprecated in ODBC 3
 
@@ -67,6 +67,9 @@
     SQLRETURN
     row_count(SQLHSTMT shdle, SQLLEN * rowcount);
 
+    SQLRETURN
+    num_result_cols(SQLSMALLINT * num_cols);
+
     const std::wstring&
     get_carob_diagids() const
     {   // the owning connection has the prefix/knows the source 

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

Reply via email to