I created a stored procedure, which saves values in a table temporal.y then I show with the "select " but only in my sqlserver works well . when you call the procedure in codeigniter I generated an empty array.
THIS IS MY PROCEDURE IN CODEIGNITER
function verificacion_ocupados($codigo,$llave_maestra){
$sql = "sp_verificacionocupados ?, ?";
$query = $this->db->query($sql,array($codigo, $llave_maestra));
$data = $query->result();
$query->free_result();
return $data;
}
THIS IS MY PROCEDURE
CREATE PROCEDURE [dbo].[sp_verificacionocupados]
@codigo int,
@llave_maestro varchar(50)
AS
DECLARE @finicio date;
DECLARE @ffinal date;
DECLARE @codigo_dias int;
DECLARE @no VARCHAR(100);
create table #pivote(
code int
);
SET @no='veremos';
BEGIN
SELECT @ffinal=Oel_Fecha_Fin,@finicio=Oel_Fecha_Inicio
FROM Operaciones_Especiales_Llave
where Em_Codigo=@codigo and Oel_Estado=2 and Th_Llave=@llave_maestro ;
IF @@ROWCOUNT>0
BEGIN
INSERT INTO #pivote VALUES (2);
END
END
SELECT code from #pivote;
GO
This is just one example of a much larger consultation I am doing . I think the problem is in the temporary table and as I call to return data.
Who has an idea what is the problem ? . Thanks in advance
change it as following.
function verificacion_ocupados($codigo,$llave_maestra)
{
$sql="sp_verificacionocupadose ?, ?";
$query=$this->db->query('call sp_verificacionocupadose("$codigo","$llave_maestra")'));
$data=$query->result();
$query->free_result();
return $data;
}