On 28-Sep-2006 Martin J. Evans wrote:
> 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
> 
> If you can supply the procedure, and a method for creating it I will see 
> what I can do - no promises for a resolution though.
> 
> Martin

For anyone following this thread Stephen gave me the procedure offline which
was:

CREATE PROCEDURE ODBC( IN A INTEGER,
      IN B INTEGER,
     OUT C INTEGER )
     LANGUAGE SQL
BEGIN
      SET C = A + B;
END

Before I went to get the DB2 ODBC driver to try this out I gave it a quick try
with DBD::DB2 and gues what - same error. It was then I realised an error in
the code.

Stephen. I would try correcting your code which calls bind_param incorrectly:

$sth->bind_param(1, \$a ); -> $sth->bind_param(1, $a );
$sth->bind_param(2, \$b ); -> $sth->bind_param(2, $b );

I'm surprised IBM did not spot this.

BTW
  what is with all those "my( $a ) = 1;" statements? You don't need the ().
  and why do "$ENV{PERL_DL_NONLAZY}=1;"?

If this still does not work let me know.

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com

Reply via email to