I need to execute a stored procedure after my form submits data. I have the stored procedure working like I want it, and I have my form working properly. I just do not know
app('db')->getPdo()->exec('exec my_stored_procedure');
for Laravel 5.4
DB::select(DB::raw("exec my_stored_procedure"));
if you want to pass parameters:
DB::select(DB::raw("exec my_stored_procedure :Param1, :Param2"),[
':Param1' => $param_1,
':Param2' => $param_2,
]);
After a long research, this works:
DB::connection("sqlsrv")->statement('exec Pro_Internal_Transfer_Note_post @mvoucherid='.$VMID);
MySql with Laravel 5.6(or above version may be)
DB::select( 'call sp($id)' );
For version 5.5 use CALL
:
return DB::select(DB::raw('call store_procedure_function(?)', [$parameter]))
Try something like this
DB::select('exec my_stored_procedure("Param1", "param2",..)');
or
DB::select('exec my_stored_procedure(?,?,..)',array($Param1,$param2));
Try this for without parameters
DB::select('EXEC my_stored_procedure')