execute_for_fetch()
execute_for_fetch($fetch[, \@status)
Use this method to execute multiple statements given as the
argument of the method, as a sub method. You may
give a reference to a subroutine that returns an array of arrays of
data. Or you may give the array of arrays as shown in the following
example. Tuple status may be given as an array reference for the
second argument:
...
my @engl = ('one','two','three');
my @ital = ('uno','due','tre');
my @germ = ('eins','zwei','drei');
my @count_values =(\@engl, \@ital, \@germ);
my $sth = $dbh->prepare("INSERT INTO count_three
(col1, col2, col3)
VALUES (?,?,?)");
my ($rc) = $sth->execute_for_fetch( sub { shift @count_values }, undef);The value of $rc is 3. Since the tuple’s
status is undefined in this example, there is none. However, if you
were to give one with the method, you could capture the tuple status
as well (e.g., my ($tuple,$rc) =
$sth->execute_for_fetch(...);). Here are the contents of
the test table after running this Perl program:
SELECT * FROM count_three; +------+------+-------+ | col1 | col2 | col3 | +------+------+-------+ | one | two | three | | uno | due | tre | | eins | zwei | drei | +------+------+-------+