db2_execute, stored procedures and null values

General discussion on Zend Core for IBM System i
Post Reply
astagl
Posts: 15
Joined: Tue Mar 09, 2010 3:11 am

db2_execute, stored procedures and null values

Post by astagl » Mon Mar 22, 2010 9:42 pm

Hello everybody!

We recently updated our i5 with the newest ZendCore updates and are running into problems calling stored procedures that return integer parameters with null values.

SQL:

Code: Select all

CREATE PROCEDURE TEST_INT( OUT OUT_INT INTEGER ) 
LANGUAGE SQL
BEGIN
SET OUT_INT = NULL;
END; 
PHP:

Code: Select all

	$conn = db2_connect("*LOCAL", $user, $pwd) or die("Connection Failed ".db2_conn_errormsg());
	$sql = 'CALL TEST_INT(?)';
	$stmt = db2_prepare($conn, $sql) or die("Prepare failed: ".db2_stmt_errormsg());
	$returnVal = 0;
	db2_bind_param($stmt, 1, "returnVal", DB2_PARAM_OUT);
	db2_execute($stmt) or die("Execute failed: ".db2_stmt_errormsg());
	echo "The stored procedure returned: ".$returnVal;
	db2_close($conn);
Returns an error of:
Indicator variable required. SQLCODE=-305

If the stored proc returns a numeric value, there is no error. What's all this about?

The ibm_db2 PECL extension is at version 1.8.1. Currently @ PECL, 1.8.3 is the latest, but everything shows up to date in the ZendCore configuration page. Does this have anything to do with it or am I missing something in my programming?

aaron-s-hawley
Posts: 46
Joined: Thu Mar 11, 2010 4:43 pm
Location: Colchester, VT
Contact:

Re: db2_execute, stored procedures and null values

Post by aaron-s-hawley » Tue Mar 23, 2010 1:01 pm

Shouldn't db2_bind_param() provide DB2_PARAM_IN as the fourth argument, not DB2_PARAM_OUT?

astagl
Posts: 15
Joined: Tue Mar 09, 2010 3:11 am

Re: db2_execute, stored procedures and null values

Post by astagl » Tue Mar 23, 2010 3:49 pm

aaron-s-hawley wrote:Shouldn't db2_bind_param() provide DB2_PARAM_IN as the fourth argument, not DB2_PARAM_OUT?
If you note the stored procedure, I have no IN parameters at all. All it does is return a value.

aaron-s-hawley
Posts: 46
Joined: Thu Mar 11, 2010 4:43 pm
Location: Colchester, VT
Contact:

Re: db2_execute, stored procedures and null values

Post by aaron-s-hawley » Wed Mar 24, 2010 1:14 pm

Why is there a question mark in the stored procedure CALL?

astagl
Posts: 15
Joined: Tue Mar 09, 2010 3:11 am

Re: db2_execute, stored procedures and null values

Post by astagl » Wed Mar 24, 2010 5:36 pm

aaron-s-hawley wrote:Why is there a question mark in the stored procedure CALL?
It is a placeholder for the outward bound param.

Post Reply