#!/usr/bin/perl use DBI; use Data::Dumper; use strict; use warnings; my %bodies = (); my $sth; my @recnos = (2284, 2285, 2286); my $dbfile="database-example.sqlite3"; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", undef, undef, { AutoCommit => 0, RaiseError => 1 }) or die("Could not open database '$dbfile': $!\n"); # this produces an empty set my $query = 'SELECT recno, body FROM body WHERE recno IN (?);'; $sth = $dbh->prepare($query) or die("prepare statement failed: $dbh->errstr()\n"); $sth->execute( join(',', @recnos) ) or die("execute statement failed: $dbh->errstr()\n"); my $bodies = $sth->fetchall_arrayref; print "Part A\n",Dumper($bodies); print "-"x39,"\n"; # this produces the expected three records my $query = 'SELECT recno, body FROM body WHERE recno IN (2284, 2285, 2286);'; $sth = $dbh->prepare($query) or die("prepare statement failed: $dbh->errstr()\n"); $sth->execute( ) or die("execute statement failed: $dbh->errstr()\n"); my $bodies = $sth->fetchall_arrayref; print "Part B\n",Dumper($bodies); $sth->finish; $dbh->disconnect; exit(0);