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.
Remove the single quotes around the bind markers:
$stmt = db2_prepare($connection, "CALL LABLIB2.AR0011CL(?, ?, ?)");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With