If you split it up so that you are only executing one SQL statement at a time, it will work fine. (using SQLite here to make it an SSCCE)
#!/usr/bin/env perl use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:SQLite:dbname=/tmp/testdb','','') or die; my @data; my $sth = $dbh->prepare ('select ?'); for my $arg (qw/one two three/) { $sth->execute ($arg); push @data, $sth->fetchrow_array; } print "$_\n" for @data;
I expect that DBI just ignores everything after the first statement if you try to do it all at once. Another alternative would be a stored procedure but the best approach depends on what you're really trying to do.
Update: Confirmed. DBI says:
Multiple SQL statements may not be combined in a single statement handle ($sth), although some databases and drivers do support this (notably Sybase and SQL Server).
In reply to Re: How to retrieve multiple output sets using DBI
by hippo
in thread How to retrieve multiple output sets using DBI
by roho
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |