Hello,

I'm trying to simply do a SELECT from an ODBC source.
It works perfectly in PHP but not in perl !
Therefore there is no problem at source or at ODBC level, it seems to reside at perl/DBI level...

What I do :

use DBI;
$dbh = DBI->connect('dbi:ODBC:' . $dsnname, $dbuser, $dbpwd) or...
$sth = $dbh->prepare($sql) or die...
do {
        my @row;
        my $line=1;
        # fetch each row in array
        while (@row = $sth->fetchrow_array())
        {
                print ($line + 1);
                print ". ";
                # print each field in a row
                for ($i=0;$i<$#row;$i++)
                {
                        print $row[$i]
                };
                print "\n";
                $line++;
        }
        # see if there's more records to show
} while ($sth->{odbc_more_results});

But even if my script is working, most of the time (not always but 80% of time ???) I get this error :

DBD::ODBC::st fetchrow_array failed: [unixODBC][IBM][System i Access ODBC Driver]Column 1: CWB0111 - A buffer passed to a system call is too small to hold return data (SQL-22018) [state was 22018 now 01004]

[unixODBC][IBM][System i Access ODBC Driver]String data right
truncation. (SQL-01004) at ./odbcdemo-perl.pl line n.

I'm not an ODBC expert, not a DBI expert, therefore I'm maybe forgetting something important to be done, but I don't find anything on the web that helped me...

Last idea, could it be due to UTF8, which would create difference in
string sizes ?

I found a similar bug in PHP :

And a thread about my problem but without solution :

But I don't understand DBI enough to understand what I should do ?

Thanks a lot for any help !

Denis

Just a precision, in my original I didn't forgot the "execute", this is not the problem.

And another precision, I get 27 rows of data (out of 126) before the error arrives...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.