in reply to SQLite select won't return SELECTed records
Are you aware that Perl and DBI both supply ample error checking methods that could help you simplify your code vastly?
my $s= 'DBI'; eval("use $s;"); if ($@) { die "$0: ERROR: $s not installed.\n"; }
can be replaced by simply
use DBI;
Also, you don't need to load the DBD module for the database. DBI will do that for you.
If you want to check programmer usage of your subroutines, see die and/or Carp::croak for how to replace
if (($cat) and (len($cat)==0)) { $s="$procname ERROR: Category was not provided. Cannot update data +base."; writeerr($s); exit 1; }
by them.
Also, you should change your connect command for DBI to be
my $dbh= DBI->connect($dsn, $user, $password, { RaiseError => 1, Print +Error => 0 });
That way, DBI will automatically notify you of all database errors and stop the program.
As your program runs, it seems to me that the database table is left empty. Maybe consider re-checking that the rows actually get filled.
For printing the results of a SELECT statement, I wrote DBIx::RunSQL::format_results, which outputs the results in table form. Maybe you can adapt the code from the routine to your needs.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SQLite select wont' return records
by bulrush (Scribe) on Oct 16, 2014 at 11:59 UTC | |
by Corion (Patriarch) on Oct 16, 2014 at 13:16 UTC | |
by bulrush (Scribe) on Oct 16, 2014 at 13:47 UTC | |
by GrandFather (Saint) on Oct 16, 2014 at 19:24 UTC |