On Tue, Oct 22, 2002 at 08:37:34PM -0400, Steve Sapovits wrote:
> 
> Looks like an Oracle error, which is what I'd expect.  I'm just
> wondering if Oracle is supposed to support this or not ...
> 
> Here's the trace output (sorry for any wrapping):

>     -> prepare for DBD::Oracle::db (DBI::db=HASH(0x335a78)~0x26b9ac 'CREATE 
> TABLE foo2 AS SELECT * FROM foo W
> HERE col_2 = ?')
>     New DBI::st (for DBD::Oracle::st, parent=DBI::db=HASH(0x26b9ac), id=)
>     dbih_setup_handle(DBI::st=HASH(0x26ba60)=>DBI::st=HASH(0x277a00), 
> DBD::Oracle::st, 33b398, Null!)
>     dbih_make_com(DBI::db=HASH(0x26b9ac), DBD::Oracle::st, 208) thr#0
>     dbd_preparse scanned 1 distinct placeholders
>     dbd_st_prepare'd sql CREATE
>     dbd_describe skipped for CREATE
>     <- prepare= DBI::st=HASH(0x26ba60) at cbindt line 13

I suspect the problem is summed up by the "dbd_describe skipped for CREATE" line.

>     -> execute for DBD::Oracle::st (DBI::st=HASH(0x26ba60)~0x277a00 1)
>        bind :p1 <== 1 (type 0)
>        bind :p1 <== 1 (size 1/2/0, ptype 5, otype 1)
>        bind :p1 <== '1' (size 1/1, otype 1, indp 0, at_exec 1)
>     !! ERROR: 1036 'ORA-01036: illegal variable name/number (DBD ERROR: 
>OCIBindByName)'
>     <- execute= undef at cbindt line 16

Try this (experimental and untested) patch:

--- oci8.c.prev Wed Oct 23 09:19:25 2002
+++ oci8.c      Wed Oct 23 09:22:58 2002
@@ -817,7 +817,7 @@
     if (long_readlen < 0)              /* trap any sillyness */
        long_readlen = 80;              /* typical oracle app default   */
 
-    if (imp_sth->stmt_type != OCI_STMT_SELECT) {
+    if (0 && imp_sth->stmt_type != OCI_STMT_SELECT) { /* XXX DISABLED, see num_fields 
+test below */
        if (DBIS->debug >= 3)
            PerlIO_printf(DBILOGFP, "    dbd_describe skipped for %s\n",
                oci_stmt_type_name(imp_sth->stmt_type));
@@ -847,6 +847,14 @@
        oci_error(h, imp_sth->errhp, status, "OCIAttrGet OCI_ATTR_PARAM_COUNT");
        return 0;
     }
+    if (num_fields == 0) {
+       if (DBIS->debug >= 3)
+           PerlIO_printf(DBILOGFP, "    dbd_describe skipped for %s (no fields 
+returned)\n",
+               oci_stmt_type_name(imp_sth->stmt_type));
+       /* imp_sth memory was cleared when created so no setup required here    */
+       return 1;
+    }
+
     DBIc_NUM_FIELDS(imp_sth) = num_fields;
     Newz(42, imp_sth->fbh, num_fields, imp_fbh_t);

But this change may cause some other issues (such as DDL statement
getting executed during prepare()) so test carefully.

Tim.

Reply via email to