in reply to Perl DBI connect cached still active
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl DBI connect cached still active
by newperldeveloper (Sexton) on Oct 29, 2020 at 11:03 UTC | |
by Corion (Patriarch) on Oct 29, 2020 at 11:11 UTC | |
by derby (Abbot) on Oct 30, 2020 at 10:43 UTC | |
by tybalt89 (Monsignor) on Oct 29, 2020 at 13:52 UTC |
In Section
Seekers of Perl Wisdom