Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-29 · container image gvenzl/oracle-free:23-slim
ORA-00909 means a built-in function was called with the wrong number of arguments. In current Oracle versions common functions such as NVL, SUM and NULLIF raise ORA-00909 for both too few and too many arguments, instead of ORA-00938/ORA-00939.
The * under the statement points at the function whose argument count is wrong. Count the arguments inside that function's brackets.
01NVL's default value ended up inside SUM
To show 0 instead of an empty total, the query says NVL(SUM(qty, 0)). The bracket of SUM closes after the 0, so SUM gets two arguments and NVL gets one. The * points at SUM.
SUM(qty) alone works but order 200 has an empty total because all its rows are NULL. Closing SUM first, NVL(SUM(qty), 0) returns 3 and 0.
Setup
CREATE TABLE order_lines (line_id NUMBER PRIMARY KEY, order_id NUMBER, qty NUMBER);
INSERT INTO order_lines VALUES (1, 100, 3);
INSERT INTO order_lines VALUES (2, 100, NULL);
INSERT INTO order_lines VALUES (3, 200, NULL);
COMMIT;Table created.
1 row created.
1 row created.
1 row created.
Commit complete.SELECT order_id, NVL(SUM(qty, 0)) AS total_qty FROM order_lines GROUP BY order_id ORDER BY order_id;SELECT order_id, NVL(SUM(qty, 0)) AS total_qty FROM order_lines GROUP BY order_id ORDER BY order_id
*
ERROR at line 1:
ORA-00909: invalid number of arguments
Help: https://docs.oracle.com/error-help/db/ora-00909/SELECT order_id, SUM(qty) AS total_qty FROM order_lines GROUP BY order_id ORDER BY order_id; ORDER_ID TOTAL_QTY
---------- ----------
100 3
200
2 rows selected.SELECT order_id, NVL(SUM(qty), 0) AS total_qty FROM order_lines GROUP BY order_id ORDER BY order_id; ORDER_ID TOTAL_QTY
---------- ----------
100 3
200 0
2 rows selected.02NVL called with three values
The query tries to pick the first non-null phone with NVL(mobile, office, 'none'). NVL takes exactly two arguments, so the * points at NVL.
NVL(mobile, office) runs but contact 3 has neither number and stays empty. COALESCE accepts any number of arguments: COALESCE(mobile, office, 'none') returns the mobile, then the office number, then none.
Setup
CREATE TABLE contacts (contact_id NUMBER PRIMARY KEY, mobile VARCHAR2(20), office VARCHAR2(20));
INSERT INTO contacts VALUES (1, '010-1111-2222', '02-123-4567');
INSERT INTO contacts VALUES (2, NULL, '02-987-6543');
INSERT INTO contacts VALUES (3, NULL, NULL);
COMMIT;Table created.
1 row created.
1 row created.
1 row created.
Commit complete.SELECT contact_id, NVL(mobile, office, 'none') AS phone FROM contacts ORDER BY contact_id;SELECT contact_id, NVL(mobile, office, 'none') AS phone FROM contacts ORDER BY contact_id
*
ERROR at line 1:
ORA-00909: invalid number of arguments
Help: https://docs.oracle.com/error-help/db/ora-00909/SELECT contact_id, NVL(mobile, office) AS phone FROM contacts ORDER BY contact_id;CONTACT_ID PHONE
---------- --------------------
1 010-1111-2222
2 02-987-6543
3
3 rows selected.SELECT contact_id, COALESCE(mobile, office, 'none') AS phone FROM contacts ORDER BY contact_id;CONTACT_ID PHONE
---------- --------------------
1 010-1111-2222
2 02-987-6543
3 none
3 rows selected.03NULLIF called with only one argument
To avoid dividing by zero, the query writes amount / NULLIF(headcount), forgetting the value to compare with. NULLIF needs two arguments and the * points at it.
The check shows that NULLIF(headcount, 0) turns 0 into NULL for department 20. With amount / NULLIF(headcount, 0) department 10 gets 3000 and department 20 gets NULL instead of an error.
Setup
CREATE TABLE dept_sales (dept_id NUMBER PRIMARY KEY, amount NUMBER, headcount NUMBER);
INSERT INTO dept_sales VALUES (10, 9000, 3);
INSERT INTO dept_sales VALUES (20, 5000, 0);
COMMIT;Table created.
1 row created.
1 row created.
Commit complete.SELECT dept_id, amount / NULLIF(headcount) AS per_person FROM dept_sales ORDER BY dept_id;SELECT dept_id, amount / NULLIF(headcount) AS per_person FROM dept_sales ORDER BY dept_id
*
ERROR at line 1:
ORA-00909: invalid number of arguments
Help: https://docs.oracle.com/error-help/db/ora-00909/SELECT dept_id, NULLIF(headcount, 0) AS divisor FROM dept_sales ORDER BY dept_id; DEPT_ID DIVISOR
---------- ----------
10 3
20
2 rows selected.SELECT dept_id, amount / NULLIF(headcount, 0) AS per_person FROM dept_sales ORDER BY dept_id; DEPT_ID PER_PERSON
---------- ----------
10 3000
20
2 rows selected.FAQ
How do I fix ORA-00909 invalid number of arguments?
Look at the function the * points to and count the arguments inside its brackets. Most often a closing bracket is in the wrong place in nested functions, such as NVL(SUM(x, 0)) instead of NVL(SUM(x), 0).
Can Oracle NVL take three arguments?
No. NVL takes exactly two. For a chain of fallbacks use COALESCE(a, b, c), which returns the first non-null value.
Why ORA-00909 and not ORA-00938 or ORA-00939?
In the tested Oracle version, NVL, SUM and NULLIF raised ORA-00909 for a wrong argument count. Other functions such as SUBSTR or ROUND still report ORA-00938 (too few) or ORA-00939 (too many).
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; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0