apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Darroch <chr...@pearsoncmg.com>
Subject Re: Column names with apr_dbd
Date Mon, 13 Feb 2006 19:38:03 GMT
Bojan Smojver wrote:

> On Mon, 2006-02-13 at 10:52 +0000, Nick Kew wrote:
> 
>> FWIW, we have an uncommitted patch that looks like this.
>> Feel free to improve it.
> 
> Thanks. I'll work on the underlying drivers in order to get this going.

   Here's a patch for the apr_dbd_oracle driver that has the
get_name function implemented.  (I hope to get back to some
delayed work on that driver in a month or two.)

Chris.

===========================================
--- apr_dbd_oracle.c.orig	2006-02-13 14:28:27.160654000 -0500
+++ apr_dbd_oracle.c	2006-02-13 14:33:24.668866000 -0500
@@ -181,6 +181,7 @@
         char *stringval;
         OCILobLocator *lobval;
     } buf;
+    const char *name;
 } define_arg;

 struct apr_dbd_prepared_t {
@@ -525,6 +526,16 @@
 }
 #endif

+static const char *dbd_oracle_get_name(const apr_dbd_results_t *res, int n)
+{
+    define_arg *val = &res->statement->out[n];
+
+    if ((n < 0) || (n >= res->statement->nout)) {
+        return NULL;
+    }
+    return val->name;
+}
+
 static int dbd_oracle_get_row(apr_pool_t *pool, apr_dbd_results_t *res,
                               apr_dbd_row_t **rowp, int rownum)
 {
@@ -988,6 +999,8 @@
     int_errorcode;
     ub2 paramtype[DBD_ORACLE_MAX_COLUMNS];
     ub2 paramsize[DBD_ORACLE_MAX_COLUMNS];
+    const char *paramname[DBD_ORACLE_MAX_COLUMNS];
+    ub4 paramnamelen[DBD_ORACLE_MAX_COLUMNS];
     /* Perl uses 0 where we used 1 */
     sql->status = OCIStmtExecute(sql->svc, stmt->stmt, sql->err, 0, 0,
                                  NULL, NULL, OCI_DESCRIBE_ONLY);
@@ -1016,6 +1029,10 @@
             sql->status = OCIAttrGet(parms, OCI_DTYPE_PARAM,
                                      &paramsize[stmt->nout],
                                      0, OCI_ATTR_DATA_SIZE, sql->err);
+            sql->status = OCIAttrGet(parms, OCI_DTYPE_PARAM,
+                                     &paramname[stmt->nout],
+                                     &paramnamelen[stmt->nout],
+                                     OCI_ATTR_NAME, sql->err);
             ++stmt->nout;
         }
     }
@@ -1033,6 +1050,8 @@
     for (i=0; i<stmt->nout; ++i) {
         stmt->out[i].type = paramtype[i];
         stmt->out[i].len = stmt->out[i].sz = paramsize[i];
+        stmt->out[i].name = apr_pstrmemdup(stmt->pool,
+                                           paramname[i], paramnamelen[i]);
         switch (stmt->out[i].type) {
         default:
             switch (stmt->out[i].type) {
@@ -1890,6 +1909,7 @@
     dbd_oracle_pvquery,
     dbd_oracle_pvselect,
     dbd_oracle_pquery,
-    dbd_oracle_pselect
+    dbd_oracle_pselect,
+    dbd_oracle_get_name
 };
 #endif
===========================================

Mime
View raw message