Update:

Oops, read that over again and see what you're saying. You're accepting SQL from a form as if it was command line. What about adding if ($sth->rows) beforehand? Then the fetch would only run if there were rows returned. Alternately allow the user to select the db they want to use beforehand, and use it the DBI->connect() string. I'm way too new at DBI and Perl in general to really answer that... and here I though there was finally a question I could answer...*sigh*

Now Irrelevant Info:

Firstly you don't have to "use database" as an SQL command like you would from a command line interface.

my $dbh = DBI->connect('DBI:DBMS_module:database_name');

This will create a connection to the DBMS, if you need to supply a username and password (suggested) then pass them as well.

my $dbh = DBI->connect('DBI:DBMS_module:database_name', 'username', 'p +assword');

The next issue is you never have to throw a go command in, these are implicit when you call any method to fetch the data you want. I simply don't have the experience w/ DBI to answer past this with as much confidence or as well as the following sources:


In reply to Re: how to catch the query retunin no rows. by Arguile
in thread how to catch the query retunin no rows. by turumkhan

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.