See $if_active in perldoc DBI
check line marked HERE in this sample of code ( since you didn't provide a Short, Self-Contained, Correct Example )
#!/usr/bin/perl
use strict; # https://perlmonks.org/?node_id=11123285
use warnings;
use DBI;
my $dbfile = 'db.11123285';
unlink $dbfile;
my $db = DBI->connect_cached(
"DBI:SQLite(RaiseError=>1,PrintError=>0):$dbfile");
eval
{
$db->do('create table note (id integer primary key, ts int, mess tex
+t)');
$db->do('insert into note (ts, mess) values (?, ?)', {}, 1, 'one');
$db->do('insert into note (ts, mess) values (?, ?)', {}, 2, 'two');
};
#system "sqlite3 $dbfile .dump";
my $sth = $db->prepare_cached('select * from note where id = ?');
$sth->bind_param(1, 2);
$sth->execute;
my @data = $sth->fetchrow_array;
use Data::Dump 'dd'; dd \@data;
$sth = $db->prepare_cached('select * from note where id = ?', {}, 1);
+# HERE
$sth->bind_param(1, 1);
$sth->execute;
@data = $sth->fetchrow_array;
use Data::Dump 'dd'; dd \@data;
unlink $dbfile; # cleanup
Outputs:
[2, 2, "two"]
[1, 1, "one"]
Note that the "still Active" message does not prevent correct execution, so something else must be causing your lack of data.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.