Hi all,

I'm using DBD::ODBC to access MS-Access on Win2K.
If I run the following script, I get sometimes wrong size!!!

For example, when table_type=8 (SQL_DOUBLE), I get 53 but the length is 15 ???

What's wrong in my script????

-----------------------------------------
#!/usr/bin/perl

use strict;
use DBI;

my ($owner, $table, $type, $descr);

# Get only table informations
$type = "TABLE";

# Get database name with 'DBI_DSN' environment variable
my $dbh = DBI->connect() || die $DBI::errstr;

my $sth_t = $dbh->table_info ();

while (my $row = $sth_t->fetch ()) {
    my $table_cat     = $row->[0];
    my $table_owner   = $row->[1];
    my $table_name    = $row->[2];
    my $table_type    = $row->[3];
    my $table_remarks = $row->[4];

    if ($table_type eq $type && $table_owner eq $owner) {
        $table = $table_name;
        $descr = $table_remarks;

my $table_name = $table;

        my $sth_f = $dbh->prepare ("Select * From $table_name Where 0=1");
        if ($DBI::err) {
            print STDERR "$0 E: $DBI::err - $DBI::errstr\n";
            next;
        }

        $sth_f->execute ();
        if ($DBI::err) {
            print STDERR "$0 E: $DBI::err + $DBI::errstr\n";
            next;
        }

print "table: $table ($descr)\n";

        my $fnames      = $sth_f->{NAME};
        my $fnullables  = $sth_f->{NULLABLE};
        my $ftypes      = $sth_f->{TYPE};
        my $fsizes      = $sth_f->{PRECISION};
        my $fscales     = $sth_f->{SCALE};

my $fname = undef;

        foreach $fname (@$fnames) {
            my $index     = shift @$ftypes;
            my $fsize     = shift @$fsizes;
            my $fscale    = shift @$fscales;
            my $fnullable = (shift @$fnullables) ? "Y" : "N";

            print "\t$fname: $index, $fsize, $fscale, $fnullable\n";
        }

    }
}

$sth_t->finish ();

$dbh->disconnect;
-----------------------------------------

Thanks,

-Dominique Cretel
[EMAIL PROTECTED]
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.456 / Virus Database: 256 - Release Date: 18/02/2003

Reply via email to