ORA-01403: No Data Found – Complete Oracle PL/SQL & SQL Troubleshooting Guide
🚨 Quick Production Summary
Error Message: ORA-01403: no data found
Immediate Causes: An explicit SELECT ... INTO statement in PL/SQL returned zero rows, an unhandled exception in custom database packages, or missing relational data during batch processing in enterprise applications like Oracle E-Business Suite (EBS).
The ORA-01403: no data found exception is one of the most widely encountered runtime errors in Oracle Database programming. While developers and Database Administrators (DBAs) see it constantly during PL/SQL development, encountering it unexpectedly in production environments can cause concurrent programs, background jobs, and application workflows to fail abruptly.
Unlike standard SQL queries—which simply return an empty result set when no matching rows exist—PL/SQL's strict execution model treats zero rows returned by a scalar SELECT ... INTO query as an explicit error condition. When Oracle cannot populate the target variables with data, it immediately interrupts execution, raises the predefined exception, and halts the transaction unless proper exception handlers are in place.
This comprehensive, production-grade guide explores why ORA-01403 occurs, how PL/SQL execution contexts handle missing data, step-by-step debugging workflows, defensive programming best practices, and real-world solutions for Oracle Database 11g, 12c, 18c, 19c, 21c, and Oracle Database 23ai.
Typical Error Message & Stack Trace
ORA-01403: no data found
ORA-06512: at "APPS.XX_CUSTOM_PKG", line 142
ORA-06512: at line 4
In enterprise production environments, this error typically manifests through specific symptoms:
- PL/SQL stored procedures, functions, or triggers terminating with an unhandled exception halt dependent business logic.
- Oracle E-Business Suite concurrent requests failing with status
ERRORand logging ORA-01403 in their log and output files. - Java or .NET applications throwing unhandled SQL exceptions because a backend procedure failed to find expected configuration or master records.
Understanding the Mechanics of ORA-01403
To understand ORA-01403, you must understand the fundamental difference between standard SQL and procedural PL/SQL queries:
- Standard SQL (
SELECT): If you run a query in SQL*Plus or SQL Developer that matches zero rows, Oracle returns zero records and completes successfully with a message like 0 rows selected. - PL/SQL (
SELECT ... INTO): When you write a query inside a PL/SQL block designed to assign values directly into program variables, Oracle expects exactly one row to be returned. If 0 rows are returned, Oracle raisesORA-01403(predefined as the exceptionNO_DATA_FOUND). If 2 or more rows are returned, Oracle raisesORA-01422: exact fetch returns more than requested number of rows.
The syntax structure that triggers ORA-01403 looks like this:
DECLARE
l_customer_name VARCHAR2(100);
BEGIN
-- If customer_id 99999 does not exist, ORA-01403 is raised here!
SELECT customer_name
INTO l_customer_name
FROM ar_customers
WHERE customer_id = 99999;
DBMS_OUTPUT.PUT_LINE('Customer: ' || l_customer_name);
END;
/
Core Root Causes in Production Environments
1. Hardcoded or Missing Reference Data
Custom packages often query static lookup tables, profile options, or configuration tables (such as FND_PROFILE or custom lookup views) expecting mandatory configuration records to exist. If a deployment script forgot to insert a required configuration row in a target environment (e.g., UAT or Production), the query fails with ORA-01403.
2. Dynamic Primary Key Lookups Without Validation
Applications frequently perform single-row lookups based on user input or transactional IDs (e.g., fetching order details, employee records, or invoice headers). If the record was deleted, archived, or never created, the lookup fails.
3. Timing and Concurrency Issues
In high-throughput multi-user systems, one transaction might delete or update a record milliseconds before another concurrent session attempts to query it using SELECT ... INTO, resulting in intermittent ORA-01403 exceptions.
Step-by-Step Troubleshooting & Debugging Workflow
Step 1 – Locate the Exact Line Number from the Error Stack
When ORA-01403 occurs in PL/SQL, the error stack provides the schema name, package/procedure name, and the exact line number where the failure happened:
SELECT name, line, text
FROM all_source
WHERE owner = 'APPS'
AND name = 'XX_CUSTOM_PKG'
AND line BETWEEN 135 AND 150;
Step 2 – Isolate and Test the Underlying Query
Extract the SQL statement from that line and execute it independently in SQL Developer or SQL*Plus by substituting the bind variables with actual test values to confirm why zero rows are returned.
Step 3 – Check for Missing Exception Handlers
Review the PL/SQL block structure. If the developer did not include an explicit EXCEPTION WHEN NO_DATA_FOUND THEN handler, the error propagates up the call stack unhandled.
Defensive Programming Best Practices to Prevent ORA-01403
To build resilient enterprise applications and prevent production crashes caused by missing data, adopt these proven PL/SQL coding standards:
1. Always Trap the Exception Explicitly
Wrap critical SELECT ... INTO statements in an exception block so your program can handle missing records gracefully rather than crashing:
DECLARE
l_customer_name VARCHAR2(100);
BEGIN
SELECT customer_name
INTO l_customer_name
FROM ar_customers
WHERE customer_id = &p_cust_id;
DBMS_OUTPUT.PUT_LINE('Found: ' || l_customer_name);
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_customer_name := 'UNKNOWN';
DBMS_OUTPUT.PUT_LINE('Warning: Customer not found. Defaulting value.');
WHEN OTHERS THEN
raise_application_error(-20001, 'Unexpected error: ' || SQLERRM);
END;
/
2. Use Aggregate Functions (MAX, SUM) Instead of Direct SELECT INTO
If the query checks for the existence of a record or retrieves a single aggregate value where zero rows is an acceptable scenario, use aggregate functions like MAX(). Aggregate functions never raise ORA-01403; instead, they return NULL when no rows match:
-- This query will NEVER raise ORA-01403. If no row exists, l_name becomes NULL.
SELECT MAX(customer_name)
INTO l_customer_name
FROM ar_customers
WHERE customer_id = &p_cust_id;
IF l_customer_name IS NULL THEN
-- Handle missing record gracefully
NULL;
END IF;
3. Use Explicit Cursors with %NOTFOUND Checks
For complex queries or multi-row checks, explicit cursors provide absolute control over fetch operations without risking unhandled scalar exceptions:
DECLARE
CURSOR c_order (p_id NUMBER) IS
SELECT order_total FROM oe_order_headers_all WHERE header_id = p_id;
l_total NUMBER;
BEGIN
OPEN c_order(12345);
FETCH c_order INTO l_total;
IF c_order%NOTFOUND THEN
DBMS_OUTPUT.PUT_LINE('Order does not exist.');
END IF;
CLOSE c_order;
END;
/
Real Production Case Study
An enterprise Oracle E-Business Suite R12 environment running a custom financial interface concurrent program started failing consistently every night during month-end processing. The concurrent request log displayed ORA-01403: no data found originating from a custom package procedure querying tax lookup codes.
The DBA reviewed the package source code at the offending line number and discovered a direct SELECT tax_rate INTO l_rate FROM xx_tax_rates WHERE lookup_code = p_code; statement. Investigation revealed that a newly added subsidiary company in the organization had generated transaction types with a new lookup code that had not been inserted into the custom xx_tax_rates table.
Resolution: The DBA inserted the missing lookup records into the table. Furthermore, the development team updated the package code to use an explicit exception handler with WHEN NO_DATA_FOUND THEN l_rate := 0; and logged a descriptive warning message, ensuring future missing codes default safely instead of crashing the financial interface.
Frequently Asked Questions (FAQ)
Does SQL standard SELECT raise ORA-01403?
No. Standard SQL queries executed directly in SQL*Plus, SQL Developer, or via JDBC execute successfully returning zero rows. ORA-01403 is exclusively a PL/SQL runtime exception triggered by scalar SELECT ... INTO assignments.
How is ORA-01403 different from ORA-01422?
ORA-01403 means too few rows were returned (zero rows). ORA-01422 means too many rows were returned (two or more rows when a single scalar variable was expected).
Can I catch ORA-01403 using standard exception syntax?
Yes. You can catch it either by name using WHEN NO_DATA_FOUND THEN or by its Oracle error code using WHEN OTHERS THEN IF SQLCODE = -1403 THEN ... END IF;.
About the Author
Rana Abdul Wahid is an Oracle Database Consultant with more than 15 years of professional experience in Oracle Database Administration, Oracle RAC, Oracle Data Guard, RMAN Backup & Recovery, Oracle E-Business Suite, Oracle Cloud Infrastructure (OCI), Performance Tuning, and Linux/Unix system administration.

Comments
Post a Comment