note 117064 added to pdostatement.bindparam

From: Date: Thu, 09 Apr 2015 17:56:18 +0000
Subject: note 117064 added to pdostatement.bindparam
Groups: php.notes 
Request: Send a blank email to php-notes+get-202218@lists.php.net to get a copy of this message
The documentation says this about the length parameter for bindParam: "To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. " For db2, I found that setting the length for the "INPUT_OUTPUT" parameters causes a problem for varchar parameters that are input parameters. The problem I found is that the stored procedure was called, but varchar input parameters were set to null inside my stored procedure and as a result, the stored procedure could not work properly. Here is the signature for my stored procedure: CREATE OR REPLACE PROCEDURE MY_SCHEMA_NAME.MY_STORED_PROCEDURE_NAME ( IN RUN_ID INTEGER,IN V_SCHEMA_NAME VARCHAR(128), OUT out_rc INTEGER,OUT out_err_message VARCHAR(100),OUT out_sqlstate CHAR(5) ,OUT out_sqlcode INT) Here is the php code that works: $command = "Call MY_SCHEMA_NAME.MY_STORED_PROCEDURE_NAME (?,?,?,?,?,?,?)"; $stmt = $this->GuestDb->prepare($command); $stmt->bindParam(1, $RUN_ID, PDO::PARAM_INT); $stmt->bindParam(2, $V_SCHEMA_NAME, PDO::PARAM_STR); $stmt->bindParam(3, $V_TABNAME, PDO::PARAM_STR); $stmt->bindParam(4, $out_rc, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT); $stmt->bindParam(5, $out_err_message, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT); $stmt->bindParam(6, $out_sqlstate, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT); $stmt->bindParam(7, $out_sqlcode, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT); Here is the php code that does not work: $command = "Call MY_SCHEMA_NAME.MY_STORED_PROCEDURE_NAME (?,?,?,?,?,?,?)"; $stmt = $this->GuestDb->prepare($command); $stmt->bindParam(1, $RUN_ID, PDO::PARAM_INT,12); $stmt->bindParam(2, $V_SCHEMA_NAME, PDO::PARAM_STR,128); $stmt->bindParam(3, $V_TABNAME, PDO::PARAM_STR,100); $stmt->bindParam(4, $out_rc, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,12); $stmt->bindParam(5, $out_err_message, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,100); $stmt->bindParam(6, $out_sqlstate, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,6); $stmt->bindParam(7, $out_sqlcode, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,12); ---- Server IP: 72.52.91.14 Probable Submitter: 129.42.208.182 (proxied: 9.66.70.167) ---- Manual Page -- http://php.net/manual/en/pdostatement.bindparam.php Edit -- https://master.php.net/note/edit/117064 Del: integrated -- https://master.php.net/note/delete/117064/integrated Del: useless -- https://master.php.net/note/delete/117064/useless Del: bad code -- https://master.php.net/note/delete/117064/bad+code Del: spam -- https://master.php.net/note/delete/117064/spam Del: non-english -- https://master.php.net/note/delete/117064/non-english Del: in docs -- https://master.php.net/note/delete/117064/in+docs Del: other reasons-- https://master.php.net/note/delete/117064 Reject -- https://master.php.net/note/reject/117064 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202218) next »