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

Created at 22-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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.