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*
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |