Oracle 23.26SQLLab-verified · 2026-11-29

ORA-00909: invalid number of arguments

A function got a number of arguments it does not accept — usually a misplaced bracket or a function used like another one.

Oracle AI Database 26ai Free 23.26.3.0.0
ORA-00909: invalid number of arguments

Jump to a cause

  1. 01NVL's default value ended up inside SUM
  2. 02NVL called with three values
  3. 03NULLIF called with only one argument

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
Setuprun as lab_a
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;
OUTPUT
Table created.


1 row created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT order_id, NVL(SUM(qty, 0)) AS total_qty FROM order_lines GROUP BY order_id ORDER BY order_id;
✕ ERROR
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/
Checkrun as lab_a
SELECT order_id, SUM(qty) AS total_qty FROM order_lines GROUP BY order_id ORDER BY order_id;
OUTPUT
  ORDER_ID  TOTAL_QTY
---------- ----------
       100          3
       200

2 rows selected.
After the fixrun as lab_a
SELECT order_id, NVL(SUM(qty), 0) AS total_qty FROM order_lines GROUP BY order_id ORDER BY order_id;
✓ SUCCESS
  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
Setuprun as lab_a
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;
OUTPUT
Table created.


1 row created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT contact_id, NVL(mobile, office, 'none') AS phone FROM contacts ORDER BY contact_id;
✕ ERROR
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/
Checkrun as lab_a
SELECT contact_id, NVL(mobile, office) AS phone FROM contacts ORDER BY contact_id;
OUTPUT
CONTACT_ID PHONE
---------- --------------------
         1 010-1111-2222
         2 02-987-6543
         3

3 rows selected.
After the fixrun as lab_a
SELECT contact_id, COALESCE(mobile, office, 'none') AS phone FROM contacts ORDER BY contact_id;
✓ SUCCESS
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
Setuprun as lab_a
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;
OUTPUT
Table created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT dept_id, amount / NULLIF(headcount) AS per_person FROM dept_sales ORDER BY dept_id;
✕ ERROR
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/
Checkrun as lab_a
SELECT dept_id, NULLIF(headcount, 0) AS divisor FROM dept_sales ORDER BY dept_id;
OUTPUT
   DEPT_ID    DIVISOR
---------- ----------
        10          3
        20

2 rows selected.
After the fixrun as lab_a
SELECT dept_id, amount / NULLIF(headcount, 0) AS per_person FROM dept_sales ORDER BY dept_id;
✓ SUCCESS
   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