The stored procedure match_animal in the following example accepts
     three different parameters:
     
      - 
       
        an input (IN) parameter that accepts the name of the first animal as
        input
        
- 
       
        an input-output (INOUT) parameter that accepts the name of the second
        animal as input and returns the string TRUEif an
        animal in the database matches that name
 
- 
       
        an output (OUT) parameter that returns the sum of the weight of the
        two identified animals
        
     In addition, the stored procedure returns a result set consisting of the
     animals listed in alphabetic order starting at the animal corresponding
     to the input value of the first parameter and ending at the animal
     corresponding to the input value of the second parameter.
    
<?php
$sql = 'CALL match_animal(?, ?, ?)';
$conn = db2_connect($database, $user, $password);
$stmt = db2_prepare($conn, $sql);
$name = "Peaches";
$second_name = "Rickety Ride";
$weight = 0;
db2_bind_param($stmt, 1, "name", DB2_PARAM_IN);
db2_bind_param($stmt, 2, "second_name", DB2_PARAM_INOUT);
db2_bind_param($stmt, 3, "weight", DB2_PARAM_OUT);
print "Values of bound parameters _before_ CALL:\n";
print "  1: {$name} 2: {$second_name} 3: {$weight}\n\n";
if (db2_execute($stmt)) {
    print "Values of bound parameters _after_ CALL:\n";
    print "  1: {$name} 2: {$second_name} 3: {$weight}\n\n";
    print "Results:\n";
    while ($row = db2_fetch_array($stmt)) {
        print "  {$row[0]}, {$row[1]}, {$row[2]}\n";
    }
}
?>
     
    Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
Values of bound parameters _before_ CALL:
  1: Peaches 2: Rickety Ride 3: 0
Values of bound parameters _after_ CALL:
  1: Peaches 2: TRUE 3: 22
Results:
  Peaches, dog, 12.3
  Pook, cat, 3.2
  Rickety Ride, goat, 9.7