Hi,
        I am using DBI with the additional DBD::ODBC module to query an
Access database.  I have not had any problems in my development environment.
However once I started started using the code in my test environment with
copied production data I started getting the following errors:

[Fri Mar  9 15:01:37 2001] C:\PerlScripts\newWriteExcel.pl: DBD::ODBC::db
select
all_arrayref failed: [Microsoft][ODBC Microsoft Access Driver]String data,
right
 truncated on column number 9 (Comments) (SQL-01004)(DBD: st_fetch/SQLFetch
(lon
g truncated) err=1) at C:\PerlScripts\newWriteExcel.pl line 22.

[Fri Mar  9 15:01:37 2001] C:\PerlScripts\newWriteExcel.pl: DBD::ODBC::db
select
all_arrayref failed: [Microsoft][ODBC Microsoft Access Driver]String data,
right
 truncated on column number 9 (Comments) (SQL-01004)
[Fri Mar  9 15:01:37 2001] C:\PerlScripts\newWriteExcel.pl: [Microsoft][ODBC
Mic
rosoft Access Driver]String data, right truncated on column number 2
(Source) (S
QL-01004)(DBD: st_fetch/SQLFetch (long truncated) err=1) at
C:\PerlScripts\newWr
iteExcel.pl line 22.

Here is an example of the code I am using:

#!/usr/bin/perl

use DBI;
use CGI qw(:standard escapeHTML);
use CGI::Carp qw(fatalsToBrowser);

#configure dsn name and odbc connect string
$database = "testdb";
$connectstring = "DBI:ODBC:$database";

sub getdata {

  local(@array, $dbh, $ary_ref, $statement);
  $statement = $_[0];
  print "$statement\n";

  #Perform query to retrive info from database
  $dbh = DBI->connect($connectstring) or die "Unable to connect to database:
$DBI::errstr\n";
  $ary_ref = $dbh->selectall_arrayref($statement);
  $dbh->disconnect;

  foreach $row(@$ary_ref) {
    @array = (@array, @$row);
  }
  return(@array);
}


if (param('table')) {
  $table = param('table');
  $spreadSheetName = param('table') . ".xls";

  $sqlStatement = "Select Distinct BusinessUnit From $table";
  print "$sqlStatement\n";
  @businessUnits = getdata("$sqlStatement");

  foreach $businessUnit(@businessUnits) {
    print "$BusinessUnit\n";
    $sqlStatement = "SELECT * from $table WHERE BusinessUnit =
'$businessUnit'";
    @firewallRule = getdata("$sqlStatement");

    foreach $rule(@firewallRule) {
      print "$rule\n";
    }
  }
} else {
  print "Need Parameters!\n";
}

If someone can tell me how to overcome the truncation error I would be very
grateful!

Sincerely,

Rupert Northcote-Green
CIS
Mellon Financial Corporation


*****************************************************************
DISCLAIMER:   The information contained in this e-mail may be confidential
and is intended solely for the use of the named addressee.  Access, copying
or re-use of the e-mail or any information contained therein by any other
person is not authorized.  If you are not the intended recipient please
notify us immediately by returning the e-mail to the originator.    

Reply via email to