Welcome Guest, Not a member yet? Register   Sign In
How to call a Stored Procedure with 'out' parameter
#1

[eluser]fatman[/eluser]
Hi,

I have a procedure defined as :
Code:
CREATE DEFINER=`root`@`localhost` PROCEDURE `int_MapColumnToCustomFields`(IN in_tableId SMALLINT , OUT out_ErrMsg VARCHAR(500))


1. How do i call it?

2. How do i get the out param?

I tried (I tried with mysql and mysqli):

Code:
$sql = "call int_MapColumnToCustomFields(?,?);";
        $params = array($id,'');
        $this->db->query($sql, $params);

But I got this error:

Quote:OUT or INOUT argument 2 for routine dortengine.int_MapColumnToCustomFields is not a variable or NEW pseudo-variable in BEFORE trigger

call int_MapColumnToCustomFields('1','');
#2

[eluser]fatman[/eluser]
Solved it Smile

the correct code is:

Code:
$sql = "call int_MapColumnToCustomFields(?,@x);";
        $params = array($id);
        $this->db->query($sql, $params);
#3

[eluser]Unknown[/eluser]
I am also into the same issues, please provide the solutions


Thanks
Shameed
#4

[eluser]Unknown[/eluser]
[quote author="abdul mohsin" date="1321120954"]but i did not get how i can access the value of the OUT parameter and use in my php file>[/quote]

Code:
$sql = "call int_MapColumnToCustomFields(?,@x);";
        $params = array($id);
        $this->db->query($sql, $params);
$sqlGetOutParam = "SELECT @x;";
$outValue = $this->db->query($sqlGetOutParam);

echo "<pre>";
print_r($outValue->result());
echo "</pre>";

Hope you will get it.




Theme © iAndrew 2016 - Forum software by © MyBB