On 28-Sep-2006 Stephen More wrote:
> Environment:
> RHEL 4
> perl-5.8.5-24.RHEL4
> perl-DBI-1.40-8
> perl-DBD-ODBC-1.13-1
> unixODBC-2.2.11-3.FC4.1
> iSeriesAccess-5.4.0-1.0.i386.rpm
>
> I am trying to call a simple stored procedure on an iSeries / AS400:
>
>#!/usr/bin/perl -w
>
> use strict;
>
> $ENV{PERL_DL_NONLAZY}=1;
>
> use DBD::ODBC;
>
> my( $dbh ) = DBI->connect('dbi:ODBC:iseries01', 'user', 'password');
> my( $sth ) = $dbh->prepare( "{call CODELIB.ODBC(?, ?, ?)}");
> my( $a ) = 1;
> my( $b ) = 2;
> my( $c ) = undef;
> $sth->bind_param(1, \$a );
> $sth->bind_param(2, \$b );
> $sth->bind_param_inout(3, \$c, 1 );
> $sth->execute();
>
> I will always get returned:
> DBD::ODBC::st execute failed: [unixODBC][IBM][iSeries Access ODBC
> Driver]Error in assignment. (SQL-22018)(DBD: st_execute/SQLExecute
> err=-1) at ./odbc.pl line 26.
>
> I opened up a support request with IBM...after sending them my traces,
> they have determined that there is a bug in the perl code:
>
> "The values for Col Def & Scale in the SQLBindparameter do not match
> with the parameters descriptions returned in the prepare "
>
> Is there someone who can fix this bug so that perl will be able to
> call an iSeries stored procedure ?
>
>
> -Thanks
> Stephen More
Stephen set up a server I could access and I've now been able to look into this.
IBM are correct in that the scale is always set to 1 but that is not why it is
failing. The procedure has a 3rd parameter which is output only. It would appear
it is failing because the undef in the 3rd output parameter before the
parameter is called is not set correctly when bound and the iSeries ODBC driver
does not like it. This does seem to differ from what the DB2 ODBC driver for
Linux does (which accepts it ok).
A workaround for now is to set output only arguments to something which is not
undef. Also the above calls to bind_param need to be changed to pass the
parameter by value. I'm attempting to find a permanent fix.
Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com