in reply to DBD::SQLite select fails

um, too much typing, it goes like this
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

    Also, if you find yourself often needing "both", the count and the data, DBIx::PreQL allows you to write your SQL in a templated fashion suitable for switching between the two forms.