Subject: | execute_array: wrong $err_count |
my $dbh = DBI->connect or die $DBI::errstr;
$dbh->{RaiseError} = 1;
$dbh->{PrintError} = 0;
$dbh->{AutoCommit} = 0;
$dbh->{ora_array_chunk_size} = 3;
$dbh->prepare('insert into mytest values (?)')
->execute_array( { ArrayTupleStatus => [] }, [
'_1', '_2', 3
, 11 ,'_22', 33
, 111 , 222 ,333
] );
shows
DBD::Oracle::st execute_array failed: ORA-24381 ...
executing 9 generated 1 errors ...
i.e. the errors of the last failed batch, instead of
3 total errors.
Patch attached.
Subject: | Oracle.pm.diff |
--- Oracle.152 Fri Oct 19 16:41:17 2012
+++ Oracle.pm Tue Oct 23 10:44:36 2012
@@ -1076,7 +1076,7 @@
sub execute_for_fetch {
my ($sth, $fetch_tuple_sub, $tuple_status) = @_;
my $row_count = 0;
- my $err_count = 0;
+ my $err_total = 0;
my $tuple_count="0E0";
my $tuple_batch_status;
my $dbh = $sth->{Database};
@@ -1096,6 +1096,7 @@
}
last unless @tuple_batch;
+ my $err_count = 0;
my $res = ora_execute_array($sth,
\@tuple_batch,
scalar(@tuple_batch),
@@ -1107,7 +1108,7 @@
} else {
$row_count = undef;
}
-
+ $err_total += $err_count;
$tuple_count+=@$tuple_batch_status;
push @$tuple_status, @$tuple_batch_status
if defined($tuple_status);
@@ -1116,8 +1117,8 @@
}
#error check here
- return $sth->set_err($DBI::stderr, "executing $tuple_count generated $err_count errors")
- if $err_count;
+ return $sth->set_err($DBI::stderr, "executing $tuple_count generated $err_total errors")
+ if $err_total;
return wantarray
? ($tuple_count, defined $row_count ? $row_count : undef)