Executing an SQL SERVER (MSSQL) Stored Procedure from laravel DB::select()

I have a proble related to this issue

If I do:

 $st = \DB::select(
        "DECLARE @liResult INT, @lsMsg VARCHAR(200);
        EXEC ONW_SP_CANCELA_EMP '000016', @liResult, @lsMsg OUTPUT;
        SELECT @liResult as result, @lsMsg as msg;"
    );

    dd($st);

I get:

[]

But if I do this (comment out the exec to SP):

$st = \DB::select(
        "DECLARE @liResult INT, @lsMsg VARCHAR(200);
        -- EXEC ONW_SP_CANCELA_EMP '000016', @liResult, @lsMsg OUTPUT;
        SELECT @liResult as result, @lsMsg as msg;"
    );

    dd($st);

I get this:

array:1 [▼ 0 => {#333 ▼ +"result": null +"msg": null } ]

An if I execute in the rdms console I do get the select correctly, do you know a work around for this?

jfhernandeze
jfhernandeze
  • 3 days ago