From: "McMahon, Chris" <[EMAIL PROTECTED]>
>  Today's project is to get a complete list of column names for each
> table in the database, and the value for the first record (row) in
> each table.  This code does the right thing for 15 tables and then
> hangs and quits without an error message on the 16th table: 
> **************************************************** use warnings; use
> Win32::ODBC; my (@tables) = $db->TableList; foreach $table (@tables) {
>  print "$table\n";
>    $db->Sql ("SELECT * FROM $table");
>    $db->FetchRow();
>    my %hash = $db->DataHash;
>    foreach $key (sort(keys %hash)) {
>     print "\t$key", '=',$hash{$key}, "\n";
>     } #end foreach
>  }
> *******************************************************
> 
>  On the 16th table, the <print "$table\n";> line executes and the
> script hangs and quits after a few seconds. 

Let me guess ... the 16th table is kinda big, ain't it?

You said you want just the first row, why do you select all then?

If you happened to use MS SQL Server/MSDE you want to change the 
SELECT statement to this:

        $db->Sql ("SELECT TOP 1 * FROM $table");

For other databases you'll have to consult the docs, but I'd be very 
surprised if they did not support something like this. Even though 
the syntax may be a little different.

HTH, Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to