Calling stored procedures in PHP (ibm_db2)
To call a stored procedure from a PHP application, you prepare and execute an SQL CALL statement. The procedure that you call can include input parameters (IN), output parameters (OUT), and input and output parameters (INOUT).
Before you begin
Obtain a connection resource by calling one of the connection functions in the ibm_db2 API. Refer to Connecting to an IBM data server database in PHP (ibm_db2).
Procedure
To call a stored procedure:
Example
Prepare and execute an SQL CALL statement.
$sql = 'CALL match_animal(?, ?)';
$stmt = db2_prepare($conn, $sql);
$second_name = "Rickety Ride";
$weight = 0;
db2_bind_param($stmt, 1, "second_name", DB2_PARAM_INOUT);
db2_bind_param($stmt, 2, "weight", DB2_PARAM_OUT);
print "Values of bound parameters _before_ CALL:\n";
print " 1: {$second_name} 2: {$weight}\n";
db2_execute($stmt);
print "Values of bound parameters _after_ CALL:\n";
print " 1: {$second_name} 2: {$weight}\n";
What to do next
If the procedure call returns one or more result sets, you can begin fetching rows from the statement resource.