Re: Is it correct that execute_array does not raise/print an error
- From: Tim.Bunce@xxxxxxxxx (Tim Bunce)
- Date: Wed, 5 Jul 2006 14:46:09 +0100
On Wed, Jul 05, 2006 at 01:38:04PM +0100, Martin J. Evans wrote:
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
D'oh. Thanks.
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.
You might not think it more useful if the batch had 10,000 tuples in it!
I think I'll stick with just a count.
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']
Um, including ParamValues is somewhat misleading in this situation.
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.
Try the attached patch on top of the previous one.
Tim.
Index: t/15array.t
===================================================================
--- t/15array.t (revision 6474)
+++ t/15array.t (working copy)
@@ -2,7 +2,7 @@
use strict;
-use Test::More tests => 50;
+use Test::More tests => 52;
## ----------------------------------------------------------------------------
## 15array.t
@@ -45,7 +45,7 @@
# -----------------------------------------------
-ok(!$sth->execute_array(
+ok(! eval { $sth->execute_array(
{
ArrayTupleStatus => $tuple_status
},
@@ -53,9 +53,11 @@
42, # scalar 42 treated as array of 42's
undef, # scalar undef treated as array of undef's
[ qw(A B C) ], # array of strings
- ),
- '... execute_array should return false'
+ ) },
+ '... execute_array should return false'
);
+ok $@, 'execute_array failure with RaiseError should have died';
+like $sth->errstr, '/executing 3 generated 1 errors/';
cmp_ok(scalar @{$rows}, '==', 2, '... we should have 2 rows');
cmp_ok(scalar @{$tuple_status}, '==', 3, '... we should have 3 tuple_status');
Index: DBI.pm
===================================================================
--- DBI.pm (revision 6616)
+++ DBI.pm (working copy)
@@ -1932,7 +1932,7 @@
}
}
my $tuples = @$tuple_status;
- return $sth->set_err(1, "executing $tuple_status generated $err_count errors")
+ return $sth->set_err(1, "executing $tuples generated $err_count errors")
if $err_count;
return scalar(@$tuple_status) || "0E0";
}
- Follow-Ups:
- Re: Is it correct that execute_array does not raise/print an error
- From: Martin J. Evans
- Re: Is it correct that execute_array does not raise/print an error
- References:
- Re: Is it correct that execute_array does not raise/print an error
- From: Tim Bunce
- Re: Is it correct that execute_array does not raise/print an error
- From: Martin J. Evans
- Re: Is it correct that execute_array does not raise/print an error
- Prev by Date: Re: Is it correct that execute_array does not raise/print an error
- Next by Date: Re: Is it correct that execute_array does not raise/print an error
- Previous by thread: Re: Is it correct that execute_array does not raise/print an error
- Next by thread: Re: Is it correct that execute_array does not raise/print an error
- Index(es):
Relevant Pages
|
|