Tim,

Thanks for the clarification and "untested" patch. I've tried it and it now
fails (returns undef) and the HandleError routine is called. The error I'm
getting now is:

executing ARRAY(0x8ce4c08) generated 1

Changing your patch to:

return $sth->set_err(1, "executing " . join(",", @{$tuple_status}) . "
generated $err_count errors")

is every so slightly more useful, since it produces:

executing 1,ARRAY(0x981d698),1,1 generated 1 errors

which makes it obvious which row failed. The error handler gets a
better error message of:

DBD::Oracle::st execute_array failed: executing 1,ARRAY(0x8869c08),1,1
generated 1 errors [for Statement "insert into mytest values (?,?)" with
ParamValues: :p1=53, :p2='one']

Just one note. This breaks t/15array.t around about line 48 because the test
has RaiseError and PrintError turned on and expects the execute_array to fail.
Turning them off before the test and back on again after fixes.

Thanks again.

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com


On 04-Jul-2006 Tim Bunce wrote:
> On Tue, Jul 04, 2006 at 02:18:33PM +0100, Martin J. Evans wrote:
>> 
>> Thanks for the explanation. You have not however convinced me this behavior
>> is
>> right. If RaiseError caused a die on error and someone wanted to ignore
>> errors
>> they could just do what they always do - turn RaiseError off and do the
>> checking themselves.
>> 
>> What I was really after was whether not dying on an error in execute_array
>> when RaiseError was enabled was by design or a an oversight.
> 
> An oversight. Though the oversight is actually in execute_for_fetch()
> which execute_array() array calls to do the real work.
> 
>> It makes a
>> difference to me since I read the DBI docs and saw nothing which said
>> RaiseError does not work with execute_array, then discovered it didn't,
>> worked around this in my DBIx extension but would like to document why I
>> have this workaround.
> 
> Try this (untested):
> 
> --- DBI.pm      (revision 6604)
> +++ DBI.pm      (working copy)
> @@ -1931,7 +1931,10 @@
>                 push @$tuple_status, [ $err, $errstr_cache{$err} ||=
> $sth->errstr, $sth->state ];
>             }
>         }
> -       return ($err_count) ? undef : scalar(@$tuple_status)||"0E0";
> +        my $tuples = @$tuple_status;
> +        return $sth->set_err(1, "executing $tuple_status generated
> $err_count errors")
> +            if $err_count;
> +       return scalar(@$tuple_status) || "0E0";
>      }
>  
> Tim.

Reply via email to