O
O
Offenso2012-04-16 18:10:02
PHP
Offenso, 2012-04-16 18:10:02

Stored procedures, out parameter. mysqli, php?

Gentlemen habravchane.
I have such a question.
Is there a procedure

CREATE PROCEDURE iotest( IN a VARCHAR(16), OUT b VARCHAR(16) )<br/>
BEGIN<br/>
 SET b = a;<br/>
END //

I want to use it like (in mysqli)
$stmt = $con-&gt;prepare(&quot;call iotest(?,?)&quot;);<br/>
$a = 'test';<br/>
$b = 'result';<br/>
$name = 'b';<br/>
$stmt-&gt;bind_param(&quot;ss&quot;, $a, %some%); // в любой комбинации: $b / &$b / $name и другое.

Googling gave only this solution:
mysqli->prepare("call iotest(?, @a); select @a;");
Which of course is a bit frustrating. And it's not clear how to return the result set and the out parameter at the same time.
What can you suggest?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Offenso, 2012-04-16
@Offenso

according to the documentation dev.mysql.com/doc/refman/5.0/en/call.html
There will always be two requests.
Separately EXECUTE and separately SELECT OUT parameters

O
Offenso, 2012-04-18
@Offenso

For those who have encountered a similar problem, switching to PostgreSQL is adequate
. They have convenient utilities for migrating from MySQL. I had to edit quite a bit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question