# Bulk Operations

- ## Execute a statement for multiple values

  $sth = $dbh->prepare("insert into table (foo,bar) values (?,?)");
  $tuples = $sth->execute_array(\%attr, \@list_of_param_array_refs);
  - returns count of executions, even ones that failed, and not rows-affected

- ## Explicit array binding

  $dbh->bind_param_array(1, \@array_of_foo_values, \%attr);
  $dbh->bind_param_array(2, \@array_of_bar_values, \%attr);
  $sth->execute_array(\%attr) # uses bind_param_array values

- ## Attributes for row-wise binding and per-tuple status:

  ArrayTupleFetch => $code_ref_or_sth row-wise binding
  ArrayTupleStatus => $array_ref return rows-affected and errors

- ## DBI provides default methods that work for all drivers

  - Some drivers support use of specific database API for very high performance

## _

Previous slide | Next slide | Back to first slide | View graphic version