// MySQL error reference

MySQL error 1318: Incorrect number of arguments

A stored procedure or function was called with more or fewer arguments than it declares. MySQL routines have no optional parameters.

Error number
1318
Name
ER_SP_WRONG_NO_OF_ARGS
SQLSTATE
42000
Category
Syntax and statements
Error message
Incorrect number of arguments for %s %s; expected %u, got %u

What it means

The message tells you what was expected and what you passed. Unlike some databases, MySQL stored routines can't have default values, so every parameter must be supplied, including OUT and INOUT ones, which need a variable.

Common causes

  • Leaving out a parameter, expecting a default.
  • Not passing a variable for an OUT parameter.
  • The routine's definition changed and callers weren't updated.

How to fix it

  1. Check the routine's parameters.

    SHOW CREATE PROCEDURE shop.place_order;
  2. Pass every parameter, using a user variable for OUT parameters.

    CALL place_order(42, 3, @order_id);
    SELECT @order_id;

Related errors

More syntax and statements errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.