dbs Wed Oct 5 17:00:34 2005 EDT
Modified files: /phpdoc/en/reference/ibm_db2/functions db2-bind-param.xml Log: Add example for all parameter types to db2_bind_param(). http://cvs.php.net/diff.php/phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml?r1=1.6&r2=1.7&ty=u Index: phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml diff -u phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml:1.6 phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml:1.7 --- phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml:1.6 Tue Jul 12 13:39:24 2005 +++ phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml Wed Oct 5 17:00:31 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. --> <refentry id="function.db2-bind-param"> <refnamediv> @@ -164,6 +164,83 @@ ]]> </screen> </example> + <example> + <title>Calling stored procedures with IN and OUT parameters</title> + <para> + The stored procedure match_animal in the following example accepts + three different parameters: + <orderedlist> + <listitem> + <para> + an input (IN) parameter that accepts the name of the first animal as + input + </para> + </listitem> + <listitem> + <para> + an input-output (INOUT) parameter that accepts the name of the second + animal as input and returns the string <literal>TRUE</literal> if an + animal in the database matches that name + </para> + </listitem> + <listitem> + <para> + an output (OUT) parameter that returns the sum of the weight of the + two identified animals + </para> + </listitem> + </orderedlist> + 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. + </para> + <programlisting role="php"> +<![CDATA[ +<?php + +$sql = 'CALL match_animal(?, ?, ?)'; +$conn = db2_connect($database, $user, $password); +$stmt = db2_prepare($conn, $sql); + +$name = "Peaches"; +$second_name = "Rickety Ride"; +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 " {$name} {$second_name} {$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"; + } +} +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +Values of bound parameters _before_ CALL: + 1: Peaches 2: Rickety Ride 3: + +Values of bound parameters _after_ CALL: + 1: Peaches 2: Rickety Ride 3: + +Results: + Peaches, dog, 12.3 + Pook, cat, 3.2 + Rickety Ride, goat, 9.7 +]]> + </screen> + </example> + </para> </refsect1>