MySQL Lists are EOL. Please join:

List:MySQL and Perl« Previous MessageNext Message »
From:Jochen Wiedmann Date:March 12 1999 6:31pm
Subject:Re: Help getting metadata from LISTFIELDS
View as plain text  
> Subject: Help getting metadata from LISTFIELDS
> Date: Fri, 12 Mar 1999 14:10:40 +0000 (GMT)
> From: Paul Sharpe <paul@stripped>
> To: msql-mysql-modules@stripped
> This is Msql-Mysql-modules-1.21_15.  Using a Mysql data source the
> following code returns a field count matching the number of fields in
> each table but no rows.  How do I access the metadata I expected this
> 'SQL EXTENSION' to return?
>   for my $table ( $dbh->tables ) {
>     print "$table\n";
>     my $sth = $dbh->prepare("LISTFIELDS $table") || die $dbh->errstr;
>     my $rc  = $sth->execute                      || die $dbh->errstr;
>     print "rows = ",$sth->rows," fields = ",$sth->{NUM_OF_FIELDS},"\n";
>     for my $row ( $sth->fetchrow_arrayref ) {
>       print "\t@$row\n";
>     }
>   }

The LISTFIELDS instruction (which is internally mysql_list_fields, of
does nothing more than returning an empty table. You can think of it as
being equivalent to

	SELECT * FROM $table WHERE 1=0

So the number 0 is correct for the rows. What do you expect it to return?

If you want the number of rows from $table, use COUNT(*).



Jochen Wiedmann						joe@stripped
"How could this be a problem in a country where		+49 7123 14887
we have Intel and Microsoft?" (Al Gore, Vanity Fair,
January 1999 issue, talking about Y2K)

Help getting metadata from LISTFIELDSPaul Sharpe12 Mar
Re: Help getting metadata from LISTFIELDSJochen Wiedmann13 Mar
  • Re: Help getting metadata from LISTFIELDSPaul Sharpe15 Mar