Preamble
In Oracle PL/SQL, the EXISTS method is a function that tells you if a specified Varray or Nested Tables element exists.
Syntax of the EXISTS method in Oracle PL/SQL
collection_name.EXISTS (n);
Method parameters or arguments
- collection_name – the name of the collection.
- EXISTS (n) – returns TRUE if the n-th element of the collection exists and FALSE otherwise.
Note:
- If n is out of tolerance, EXISTS returns FALSE instead of calling the predefined exception SUBSCRIPT_OUTSIDE_LIMIT.
- For a remote item, EXISTS (n) returns FALSE even if DELETE has saved a place for it.
- See also collection methods: DELETE, TRIM, EXTEND, FIRST and LAST, COUNT, LIMIT, PRIOR and NEXT.
Consider an example to understand how to use the EXISTS collection method in Oracle PL/SQL.
EXISTS example with Nested Tables
Consider an example that initializes Nested Tables with four elements, deletes the second element and prints either the value or the status of the elements from 1 to 6.
DECLARE
TYPE NumList IS TABLE OF INTEGER;
n NumList := NumList(1,3,5,7);
BEGIN
n.DELETE(2); -- Delete the second element
FOR i IN 1...6 LOOP
IF n.EXISTS(i) THEN
DBMS_OUTPUT.PUT_LINE('n(' || i || ') = ' || n(i));
ELSE
DBMS_OUTPUT.PUT_LINE('n(' || i || ') does not exist');
END IF;
END LOOP;
END;
Result:
n(1) = 1
n(2) does not exist
n(3) = 5
n(4) = 7
n(5) does not exist
n(6) does not exist
PL/SQL tutorial: Collection Method EXISTS in Oracle Database
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of clouds, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
How to Enable Intelligent Healthcare Cost Visibility with Enteros Database Software and Operational Analytics
- 26 June 2026
- Software Engineering
Introduction Healthcare organizations are investing heavily in digital transformation to improve patient outcomes, streamline clinical operations, and support data-driven decision-making. From electronic health records (EHRs) and telemedicine platforms to AI-powered diagnostics and cloud-native healthcare applications, technology has become the foundation of modern healthcare delivery. Today’s healthcare ecosystems support a wide range of mission-critical systems, including: … Continue reading “How to Enable Intelligent Healthcare Cost Visibility with Enteros Database Software and Operational Analytics”
How to Improve Healthcare Infrastructure Performance with Enteros Database Management and Cost Estimation Intelligence
Introduction Healthcare organizations are rapidly transforming their IT environments to support digital patient experiences, connected medical devices, artificial intelligence (AI), telemedicine, and cloud-native healthcare applications. Hospitals, clinics, research institutions, and healthcare providers rely on technology to deliver faster, safer, and more efficient patient care. Today’s healthcare infrastructure supports a wide range of mission-critical systems, including: … Continue reading “How to Improve Healthcare Infrastructure Performance with Enteros Database Management and Cost Estimation Intelligence”
Improving Application Scalability Through AI-Powered Database Workload Analysis
In today’s digital economy, application scalability has become a critical requirement for enterprise success. Businesses are expected to deliver fast, reliable, and seamless digital experiences even as user demand, transaction volumes, and data complexity continue to grow. Whether supporting e-commerce platforms, financial applications, SaaS products, streaming services, or enterprise systems, scalable applications are essential for … Continue reading “Improving Application Scalability Through AI-Powered Database Workload Analysis”
Why Modern Enterprises Need Autonomous Database Performance Optimization
In today’s digital economy, enterprise success depends on the speed, reliability, and scalability of data-driven applications. Whether organizations operate in financial services, e-commerce, healthcare, SaaS, telecommunications, or manufacturing, databases power the critical systems behind customer experiences, transactions, analytics, and operational workflows. As businesses continue to expand their digital infrastructure, database environments are becoming increasingly complex. … Continue reading “Why Modern Enterprises Need Autonomous Database Performance Optimization”