Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4
ERROR 1318 means a stored procedure or function was called with the wrong number of arguments. The message tells you which routine and both counts, for example expected 2, got 1. MySQL has no optional or default parameters, so every parameter must be passed.
Below are three cases: a missing IN argument, a missing OUT argument, and an extra argument to a function. In each, information_schema.PARAMETERS showed the real parameter list, and the call worked once it matched.
01An IN argument is missing in CALL
add_order takes p_customer_id and p_amount. CALL add_order(7); failed with expected 2, got 1.
information_schema.PARAMETERS listed both IN parameters in order. CALL add_order(7, 15000); then inserted one row with customer_id = 7 and amount = 15000.
Setup
CREATE TABLE orders (id INT AUTO_INCREMENT PRIMARY KEY, customer_id INT, amount INT);
CREATE PROCEDURE add_order(IN p_customer_id INT, IN p_amount INT)
INSERT INTO orders (customer_id, amount) VALUES (p_customer_id, p_amount);Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)CALL add_order(7);ERROR 1318 (42000): Incorrect number of arguments for PROCEDURE lab_a.add_order; expected 2, got 1SELECT ORDINAL_POSITION AS pos, PARAMETER_MODE AS mode, PARAMETER_NAME AS name, DATA_TYPE AS type
FROM information_schema.PARAMETERS
WHERE SPECIFIC_SCHEMA = DATABASE() AND SPECIFIC_NAME = 'add_order'
ORDER BY ORDINAL_POSITION;+-----+------+---------------+------+
| pos | mode | name | type |
+-----+------+---------------+------+
| 1 | IN | p_customer_id | int |
| 2 | IN | p_amount | int |
+-----+------+---------------+------+
2 rows in set (0.00 sec)If the procedure was changed recently, check every caller. Callers written for the old parameter list get this error.
CALL add_order(7, 15000);
SELECT * FROM orders;Query OK, 1 row affected (0.01 sec)
+----+-------------+--------+
| id | customer_id | amount |
+----+-------------+--------+
| 1 | 7 | 15000 |
+----+-------------+--------+
1 row in set (0.00 sec)02The OUT argument is left out
OUT parameters count too. get_customer_name(IN p_id, OUT p_name) was called as CALL get_customer_name(1); and failed with expected 2, got 1.
PARAMETERS showed p_name with mode OUT. Passing a user variable, CALL get_customer_name(1, @name);, worked, and SELECT @name returned Kim.
Setup
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(30));
INSERT INTO customers VALUES (1, 'Kim');
CREATE PROCEDURE get_customer_name(IN p_id INT, OUT p_name VARCHAR(30))
SELECT name INTO p_name FROM customers WHERE id = p_id;Query OK, 0 rows affected (0.01 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)CALL get_customer_name(1);ERROR 1318 (42000): Incorrect number of arguments for PROCEDURE lab_a.get_customer_name; expected 2, got 1SELECT ORDINAL_POSITION AS pos, PARAMETER_MODE AS mode, PARAMETER_NAME AS name
FROM information_schema.PARAMETERS
WHERE SPECIFIC_SCHEMA = DATABASE() AND SPECIFIC_NAME = 'get_customer_name'
ORDER BY ORDINAL_POSITION;+-----+------+--------+
| pos | mode | name |
+-----+------+--------+
| 1 | IN | p_id |
| 2 | OUT | p_name |
+-----+------+--------+
2 rows in set (0.00 sec)CALL get_customer_name(1, @name);
SELECT @name AS name;Query OK, 1 row affected (0.00 sec)
+------+
| name |
+------+
| Kim |
+------+
1 row in set (0.00 sec)03Too many arguments to a stored function
The same error appears for stored functions, with FUNCTION in the message. add_tax(p_price) takes one argument, but SELECT add_tax(1000, 0.08) passed two: expected 1, got 2.
information_schema.ROUTINES and PARAMETERS showed it returns int and has only p_price. SELECT add_tax(1000) returned 1100.
Setup
CREATE FUNCTION lab_a.add_tax(p_price INT) RETURNS INT DETERMINISTIC
RETURN ROUND(p_price * 1.1);Query OK, 0 rows affected (0.01 sec)SELECT add_tax(1000, 0.08) AS price;ERROR 1318 (42000): Incorrect number of arguments for FUNCTION lab_a.add_tax; expected 1, got 2SELECT ROUTINE_NAME, DTD_IDENTIFIER AS returns_type
FROM information_schema.ROUTINES
WHERE ROUTINE_SCHEMA = DATABASE() AND ROUTINE_NAME = 'add_tax';
SELECT ORDINAL_POSITION AS pos, PARAMETER_NAME AS name, DATA_TYPE AS type
FROM information_schema.PARAMETERS
WHERE SPECIFIC_SCHEMA = DATABASE() AND SPECIFIC_NAME = 'add_tax' AND ORDINAL_POSITION > 0;+--------------+--------------+
| ROUTINE_NAME | returns_type |
+--------------+--------------+
| add_tax | int |
+--------------+--------------+
1 row in set (0.00 sec)
+-----+---------+------+
| pos | name | type |
+-----+---------+------+
| 1 | p_price | int |
+-----+---------+------+
1 row in set (0.00 sec)SELECT add_tax(1000) AS price;+-------+
| price |
+-------+
| 1100 |
+-------+
1 row in set (0.00 sec)FAQ
How do I see the parameters of a MySQL stored procedure?
Query information_schema.PARAMETERS with SPECIFIC_SCHEMA and SPECIFIC_NAME, ordered by ORDINAL_POSITION. It shows the position, mode (IN/OUT/INOUT), name and type of each parameter.
Do I have to pass OUT parameters in CALL?
Yes. OUT parameters are counted. Leaving one out gave ERROR 1318 here. Pass a user variable like @name and read it with SELECT @name after the call.
Can MySQL procedures have optional or default parameters?
No. The call must pass exactly as many arguments as the routine declares. In the tests above, both too few and too many arguments gave ERROR 1318.
Does ERROR 1318 also happen with functions?
Yes. The message then says FUNCTION instead of PROCEDURE, for example Incorrect number of arguments for FUNCTION lab_a.add_tax; expected 1, got 2.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13