in reply to DBD::SQLite select fails
sub prepex { my( $sql, @bindvalues ) = @_; my $row; eval { $row = $dbh->selectrow_arrayref( $sql, {}, @bindvalues );; 1; } or do { writeerr( $@ ); ...; }; return $row->[0] unless wantarray; return @$row; }
RaiseError tells you (via $@ )whether prepare or execute or fetch failed
If you want the number of rows selected, COUNT(), like
SELECT COUNT(*) FROM data WHERE skey='Stuff'
or using placeholders/bindvalues
prepex( q{ SELECT COUNT(*) FROM data WHERE skey=? }, 'Stuff', );
see also this and DBI recipes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBD::SQLite select fails
by Corion (Patriarch) on Aug 12, 2014 at 11:42 UTC |