SQLSTATE[42000]: Syntax error or access violation: 1318 Incorrect number of arguments for PROCEDURE

Updated at 21-Aug-2022, By samar

SQLSTATE[42000]: Syntax error or access violation: 1318 Incorrect number of arguments for PROCEDURE

We will use programming in this lesson to attempt to solve the "SQLSTATE[42000]: Syntax error or access violation: 1318 Incorrect number of arguments for PROCEDURE".

Help me to find out the solution for error `SQLSTATE[42000]: Syntax error or access violation: 1318 Incorrect number of arguments for PROCEDURE`.
  • This error occurs when you created procedure with a number of arguments and call with a different number of arguments or without any argument. You have to use CALL procedure_name(arguments) to call the procedure in Laravel.

    You have to pass the arguments to procedure while calling the procedure. Like below.

    routes\web.php

    Route::get('call-procedure', function () {
        $userId = 1;
        $getPost = DB::select(
           'CALL get_posts_by_userid('.$userId.')'
        );
        dd($getPost);
    });
    
    

    Create stored procedure using laravel

Back to code snippet queries related laravel