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.


In reply to Re: SQLite select wont' return records by Corion
in thread SQLite select won't return SELECTed records by bulrush

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.