Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - db2_bind_param Describe Param Failed

The Code

$options = array('autocommit' => DB2_AUTOCOMMIT_OFF);
$stmt = db2_prepare($connection, "CALL LABLIB2.AR0011CL('?','?','?')");

$connection = db2_connect ( AS400_DATABASE, IS_USER_NAME, IS_USER_PASS, $options );
if (! $connection) {
     handleError("Unable to connect to the database.", 2);
}

$REF = "1234567891123456789122";
$PSSN = '123456789';
$SSSN = 123456789;

db2_bind_param($stmt, 1, 'REF',  DB2_PARAM_INOUT, DB2_CHAR, 22); //ERROR
db2_bind_param($stmt, 2, "PSSN", DB2_PARAM_INOUT, DB2_CHAR, 9); //ERROR
db2_bind_param($stmt, 3, "SSSN", DB2_PARAM_INOUT, DB2_CHAR, 9); //ERROR

db2_execute($stmt);

I see at this link the answer was to fix the PTF versions. However, that is for "complex queries". This is a very simple program call.

This code works fine in our live iSeries, which is on PHP 5.2.17

This code does not work in our development iSeries, which is now on PHP 5.4.0. The db2_bind_param lines all throw the same error message.

Was there some major change in 5.2.x to 5.4? Or is this completely unrelated?

I've tried various methods of variable declaration: single quotes, double quotes, no quotes... but none of it has made a difference because of PHP's loosely typed syntax.

Also tried removing the single quotes around each parameter in the SQL call, which then just generates an error during the prepare.

like image 728
adam Avatar asked Jun 30 '26 11:06

adam


1 Answers

Remove the single quotes around the bind markers:

$stmt = db2_prepare($connection, "CALL LABLIB2.AR0011CL(?, ?, ?)");
like image 114
tessus Avatar answered Jul 01 '26 23:07

tessus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!