Oracle 23.26SQLLab-verified · 2026-11-29

ORA-00938: not enough arguments for function

A function was called with fewer arguments than it requires, usually because a closing parenthesis is in the wrong place.

Oracle AI Database 26ai Free 23.26.3.0.0
ORA-00938: not enough arguments for function

Jump to a cause

  1. 01The INSTR search string ended up outside INSTR's parentheses
  2. 02DECODE has a search value but no result
  3. 03LPAD's length and pad character went inside TO_CHAR

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-00938 means Oracle counted the arguments of a function and found too few. With nested functions, the cause is usually not a forgotten argument but a parenthesis in the wrong place: the argument is there, it just belongs to a different function.

The * under the statement points at the function that is short of arguments. Count its arguments between its own parentheses.

01The INSTR search string ended up outside INSTR's parentheses

To take the part of an email before @, the query was written as SUBSTR(email, 1, INSTR(email) - 1, '@'). INSTR closed after email, so it got one argument, and '@' became a fourth argument of SUBSTR. The * points at INSTR.

Moving '@' inside gives INSTR(email, '@') = 4 and 8, and the result is kim and lee.dev.

Setup
Setuprun as lab_a
CREATE TABLE members (member_id NUMBER PRIMARY KEY, email VARCHAR2(50));
INSERT INTO members VALUES (1, 'kim@example.com');
INSERT INTO members VALUES (2, 'lee.dev@example.co.kr');
COMMIT;
OUTPUT
Table created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT member_id, SUBSTR(email, 1, INSTR(email) - 1, '@') AS user_name FROM members ORDER BY member_id;
✕ ERROR
SELECT member_id, SUBSTR(email, 1, INSTR(email) - 1, '@') AS user_name FROM members ORDER BY member_id
                                   *
ERROR at line 1:
ORA-00938: not enough arguments for function
Help: https://docs.oracle.com/error-help/db/ora-00938/
Checkrun as lab_a
SELECT member_id, INSTR(email, '@') AS at_pos FROM members ORDER BY member_id;
OUTPUT
 MEMBER_ID     AT_POS
---------- ----------
         1          4
         2          8

2 rows selected.
After the fixrun as lab_a
COLUMN user_name FORMAT A10
SELECT member_id, SUBSTR(email, 1, INSTR(email, '@') - 1) AS user_name FROM members ORDER BY member_id;
✓ SUCCESS
 MEMBER_ID USER_NAME
---------- ----------
         1 kim
         2 lee.dev

2 rows selected.

02DECODE has a search value but no result

DECODE(status, 'P') has only the expression and one search value. DECODE needs at least three arguments: expression, search, result.

With DECODE(status, 'P', 'Paid') the query runs, but rows that match nothing (S, C) return NULL. Adding more pairs and a default, DECODE(status, 'P', 'Paid', 'S', 'Shipped', 'Other'), returns Paid / Shipped / Other.

Setup
Setuprun as lab_a
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, status VARCHAR2(1));
INSERT INTO orders VALUES (1, 'P');
INSERT INTO orders VALUES (2, 'S');
INSERT INTO orders VALUES (3, 'C');
COMMIT;
OUTPUT
Table created.


1 row created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT order_id, DECODE(status, 'P') AS status_name FROM orders ORDER BY order_id;
✕ ERROR
SELECT order_id, DECODE(status, 'P') AS status_name FROM orders ORDER BY order_id
                 *
ERROR at line 1:
ORA-00938: not enough arguments for function
Help: https://docs.oracle.com/error-help/db/ora-00938/
Checkrun as lab_a
COLUMN status FORMAT A6
COLUMN status_name FORMAT A11
SELECT order_id, status, DECODE(status, 'P', 'Paid') AS status_name FROM orders ORDER BY order_id;
OUTPUT
  ORDER_ID STATUS STATUS_NAME
---------- ------ -----------
         1 P      Paid
         2 S
         3 C

3 rows selected.
After the fixrun as lab_a
COLUMN status FORMAT A6
COLUMN status_name FORMAT A11
SELECT order_id, status, DECODE(status, 'P', 'Paid', 'S', 'Shipped', 'Other') AS status_name FROM orders ORDER BY order_id;
✓ SUCCESS
  ORDER_ID STATUS STATUS_NAME
---------- ------ -----------
         1 P      Paid
         2 S      Shipped
         3 C      Other

3 rows selected.

03LPAD's length and pad character went inside TO_CHAR

For zero-padded codes, LPAD(TO_CHAR(emp_id, 6, '0')) puts 6, '0' inside TO_CHAR, so LPAD gets only one argument. The * points at LPAD.

The check shows that LPAD without a pad character pads with spaces ([ 7]) and with '0' gives 000007. Closing TO_CHAR first, LPAD(TO_CHAR(emp_id), 6, '0'), returns 000007 and 001234.

Setup
Setuprun as lab_a
CREATE TABLE employees (emp_id NUMBER PRIMARY KEY, emp_name VARCHAR2(30));
INSERT INTO employees VALUES (7, 'Kim');
INSERT INTO employees VALUES (1234, 'Lee');
COMMIT;
OUTPUT
Table created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT emp_id, LPAD(TO_CHAR(emp_id, 6, '0')) AS emp_code FROM employees ORDER BY emp_id;
✕ ERROR
SELECT emp_id, LPAD(TO_CHAR(emp_id, 6, '0')) AS emp_code FROM employees ORDER BY emp_id
               *
ERROR at line 1:
ORA-00938: not enough arguments for function
Help: https://docs.oracle.com/error-help/db/ora-00938/
Checkrun as lab_a
COLUMN default_pad FORMAT A11
COLUMN zero_pad FORMAT A8
SELECT emp_id, '[' || LPAD(emp_id, 6) || ']' AS default_pad, LPAD(emp_id, 6, '0') AS zero_pad FROM employees ORDER BY emp_id;
OUTPUT
    EMP_ID DEFAULT_PAD ZERO_PAD
---------- ----------- --------
         7 [     7]    000007
      1234 [  1234]    001234

2 rows selected.
After the fixrun as lab_a
COLUMN emp_code FORMAT A8
SELECT emp_id, LPAD(TO_CHAR(emp_id), 6, '0') AS emp_code FROM employees ORDER BY emp_id;
✓ SUCCESS
    EMP_ID EMP_CODE
---------- --------
         7 000007
      1234 001234

2 rows selected.

FAQ

How do I fix ORA-00938 not enough arguments for function?

Look at the function under the * and count its arguments between its own parentheses. In nested calls, an argument has usually slipped outside or inside the wrong parentheses; move it back.

Why does DECODE give ORA-00938?

DECODE needs at least an expression, a search value and a result. DECODE(status, 'P') has no result. Add it: DECODE(status, 'P', 'Paid').

What does ORA-00938 mean in Oracle?

A built-in function such as SUBSTR, INSTR, DECODE or LPAD was called with fewer arguments than its minimum.

What is the difference between ORA-00938 and ORA-00939?

ORA-00938 is too few arguments, ORA-00939 is too many. A misplaced parenthesis in nested functions often causes one of each: the inner function gets too few or too many, depending on which way the argument moved.

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