On Fri, Nov 01, 2002 at 02:57:44PM +0100, Georg Botorog wrote:
> Hi,
> 
> I am using DBI and DBD::Oracle. Is there any possibility to get the
> names of the bind variables back from OCI, such as returned by
> OCIStmtGetBindInfo()?
> 
> The background is: I get a statement (defined elswhere) where the
> placeholders for the bind variables have the syntax ":name" (not "?")
> together with the necessary values. To bind the variables, I need to
> know their names (binding by position does not work here). Of course, I
> could parse the statement, and get the variable names. However, OCI has
> this information already, thus it would be silly not to use it. So my
> question is: does DBI, DBD, or any other package pass this information
> from OCI?

The attached patch implements the new $sth->{ParamValues} attribute for
DBD::Oracle.

Then you can do

        @names = keys %{ $sth->{ParamValues} };

Tim.
Common subdirectories: DBD-Oracle-1.12/Oracle.ex and DBD-Oracle-1.1201/Oracle.ex
diff -u DBD-Oracle-1.12/Oracle.pm DBD-Oracle-1.1201/Oracle.pm
--- DBD-Oracle-1.12/Oracle.pm   Fri Aug 31 17:27:17 2001
+++ DBD-Oracle-1.1201/Oracle.pm Fri Jun 14 16:10:52 2002
@@ -10,7 +10,7 @@
 
 require 5.003;
 
-$DBD::Oracle::VERSION = '1.12';
+$DBD::Oracle::VERSION = '1.1201';
 
 my $ORACLE_ENV  = ($^O eq 'VMS') ? 'ORA_ROOT' : 'ORACLE_HOME';
 
diff -u DBD-Oracle-1.12/dbdimp.c DBD-Oracle-1.1201/dbdimp.c
--- DBD-Oracle-1.12/dbdimp.c    Wed Aug 29 20:39:15 2001
+++ DBD-Oracle-1.1201/dbdimp.c  Fri Jun 14 16:01:27 2002
@@ -1823,7 +1823,27 @@
 
     i = DBIc_NUM_FIELDS(imp_sth);
 
-    if (kl==11 && strEQ(key, "ora_lengths")) {
+    if (kl==4 && strEQ(key, "NAME")) {
+       AV *av = newAV();
+       retsv = newRV(sv_2mortal((SV*)av));
+       while(--i >= 0)
+           av_store(av, i, newSVpv((char*)imp_sth->fbh[i].name,0));
+
+    } else if (kl==11 && strEQ(key, "ParamValues")) {
+       HV *pvhv = newHV();
+       SV *sv;
+       char *key;
+       I32 keylen;
+warn("ParamValues ParamValues");
+       hv_iterinit(imp_sth->all_params_hv);
+       while ( (sv = hv_iternextsv(imp_sth->all_params_hv, &key, &keylen)) ) {
+           phs_t *phs = (phs_t*)(void*)SvPVX(sv);       /* placeholder struct   */
+           hv_store(pvhv, key, keylen, newSVsv(phs->sv), 0);
+       }
+       retsv = newRV_noinc(pvhv);
+       cacheit = FALSE;
+
+    } else if (kl==11 && strEQ(key, "ora_lengths")) {
        AV *av = newAV();
        retsv = newRV(sv_2mortal((SV*)av));
        while(--i >= 0)
@@ -1866,12 +1886,6 @@
     } else if (kl==17 && strEQ(key, "ora_est_row_width")) {
        retsv = newSViv(imp_sth->est_width);
        cacheit = TRUE;
-
-    } else if (kl==4 && strEQ(key, "NAME")) {
-       AV *av = newAV();
-       retsv = newRV(sv_2mortal((SV*)av));
-       while(--i >= 0)
-           av_store(av, i, newSVpv((char*)imp_sth->fbh[i].name,0));
 
     } else if (kl==8 && strEQ(key, "NULLABLE")) {
        AV *av = newAV();
Common subdirectories: DBD-Oracle-1.12/hints and DBD-Oracle-1.1201/hints
Common subdirectories: DBD-Oracle-1.12/t and DBD-Oracle-1.1201/t

Reply via email to