I am struggling with getting this to work.
We have a Codeigniter based site which is soon moving to a new server. I have been asked to remove the few direct mssql_* calls in the code for this. In general this is easy.
However there are a couple of places where the system uses output parameters and I cannot get these to return anything. Repeated web searches have not produced anything that works.
Reduced to the basics, a test stored proc:-
CREATE PROCEDURE [dbo].[output_test](
@p_status CHAR(1) OUTPUT
) AS
BEGIN
SET @p_status = '2'
END
Trying to use the Codeigniter routines, with transactions:-
$p_status = 0;
$query = 'EXEC dbo.output_test ?';
$this->db->trans_start();
$q = $this->db->query($query, array(&$p_status));
echo "*****".$p_status."*****";
$query = $this->db->query('SELECT @p_status AS p_status');
$this->db->trans_complete();
echo "*****".$p_status."*****";
if(isset($query->num_rows) && $query->num_rows > 0)
{
foreach($query->result() as $arr)
{
$return['status'] = $arr->p_status;
}
}
This just gives me Must declare the scalar variable "@p_status" .
I have tried pretty much every alternative to that in the rather limited Codeignitor driver without any improvement. It doesn't matter if the output parm is passed by reference or value.
Any suggestions?
I realise I could just SELECT the var in this demo case, but not possible in the full problem, as I am trying to return a result set as well from some procedures, and to avoid returning multiple result sets I would like to modify these to return the status as an output var instead of being a 2nd result set.