DBI does not do what I expect...



Hi,

I am working with a CGI to inspect a database, and I want to include a
count of records in each table in the display. I have two screens
available in the UI: one to list the tables in the d/b, and the other to
show the records in each table. I want to provide a preview of how big
each table is in the table listing, so the code preparing the table list
is doing this:

my $ary_ref = $dbh->selectcol_arrayref ( "SHOW TABLES FROM $db_name" );
# Construct a bullet list using the ul() and li functions. Each item
# is a hyperlink that re-invokes the script to display a particular
table.
my @item;
foreach my $tbl_name (@{$ary_ref}) {
my $url = sprintf ("%s?tbl_name=%s", url(), escape($tbl_name));
my $link = a ({-href => $url}, escapeHTML($tbl_name));
my $sth = $dbh->prepare ( qq (
SELECT COUNT(*) FROM $tbl_name ) );
my $rv = $sth->execute();
my $rows = $sth->rows;
push (@item, li ($link . " $rows in table" ) );
}
print ul (@item);

But when I execute the SQL, I only get "1" returned for each "$rows",
rather than what I expect, the number of rows.

Why is this not working for me?

Thanks,
Mark
.



Relevant Pages

  • RE: Userform to add and update a table
    ... One of the most common scenarios in application development is to display ... the walkthrough illustrates many of the basic ... Access to a server with the Pubs SQL Server sample database. ... Creating the Windows Form. ...
    (microsoft.public.sqlserver.programming)
  • Re: Picture property for Access 2K forms
    ... and it works great...until you look at the database size involved. ... or by simply scaling down the image display in the ... > supported by those filters. ... To associate a graphic file with an OLE Server, ...
    (microsoft.public.access.devtoolkits)
  • Re: Unknown Maiden Name [WAS how-to ruin a perfectly good FGS]
    ... through at the beginning of my database, ... or display your information in the fields you intended for them. ... the names in a manner you didn't intend and the meaning has become ... If my data is on the Internet and people don't understand it, ...
    (soc.genealogy.methods)
  • RE: Requery on command button not working
    ... Are these calculations coming from "across the ... See http://www.QBuilt.com for all your database needs. ... >> The CPU is busy executing your request. ... >>> buttons the intention is to display the releveant data for that period. ...
    (microsoft.public.access.forms)
  • Re: Creating Dynamic URLs
    ... > then searched for in the database. ... >> I specify what page to include/what content to display in the event ... A CGI script is a program that generates as output the HTML that the web server will send to the browser. ... Usually, the script takes arguments from the URL to decide what to display, and very often it will obtain some of the data on the page from a database. ...
    (comp.lang.php)