I'm trying to call a stored procedure by Laravel 5.5 but I can not. I'm using SQL Server.
Follow the stored procedure:
declare @CodigoRet int
exec Generator 'LancaContaContabil', @Codigo = @CodigoRet output
Select @CodigoRet
I researched a lot and first tried the simplest way:
$results = DB::select(DB::raw('DECLARE @CodigoRet INT; execute Generator
\'LancaContaContabil\', @Codigo = @CodigoRet OUTPUT;'));
echo $results;
The above code gives the following error: "The active result for the query contains no fields".
I also tried with the statement, but it only returns 1, it follows below:
$results = DB::statement('DECLARE @CodigoRet INT; EXEC Generator
\'LancaContaContabil\', @Codigo = @CodigoRet OUTPUT;');
echo $results;
die;
I also tried creating the procedure and calling it, but it gives the same problem ("The active result for the query contains no fields"), as if it had no data returning from the select:
$results = DB::select('EXECUTE testeproc');
echo $results;
die;
I'm doing something wrong or is there an easier way to call this stored procedure in laravel?