Preamble
The cursor is certain operator SELECT which is declared in PLSQL code. Let’s consider three different syntaxes of the cursor declaration.
A CURSOR WITHOUT PARAMETERS (SIMPLE)
Cursor announcement without any parameters, simple cursor.
Syntax
CURSOR cursor_name
IS
SELECT_statement;
For example, you can define a cursor called c1 as shown below.
CURSOR c1
IS
SELECT course_number
FROM courses_tbl
WHERE course_name = name_in;
The resultant set of this cursor is all course_numbers in which course_name matches variable name_in.
Below is the function that uses this cursor.
CREATE OR REPLACE Function FindCourse
( name_in IN varchar2 )
RETURN number
IS
cnumber number;
CURSOR c1
IS
SELECT course_number
FROM courses_tbl
WHERE course_name = name_in;
BEGIN
OPEN c1;
FETCH c1 INTO cnumber;
if c1%notfound then
cnumber := 9999;
end if;
CLOSE c1;
RETURN cnumber;
END;
PARAMETER CURSOR
Let’s declare a cursor with parameters.
Syntax
CURSOR cursor_name (parameter_list)
IS
SELECT_statement;
For example, you can define a cursor called c2, as shown below.
CURSOR c2 (subject_id_in IN varchar2)
IS
SELECT course_number
FROM courses_tbl
WHERE subject_id = subject_id_in;
The result set of this cursor is all course_numbers where subject_id corresponds to subject_id obtained with the cursor using the subject_id_in parameter.
A CURSOR WITH RETURN CONDITION
Finally, we can announce the cursor with a return condition.
Syntax
CURSOR cursor_name
RETURN field%ROWTYPE
IS
SELECT_statement;
For example, you can define a cursor called c3, as shown below.
CURSOR c3
RETURN courses_tbl%ROWTYPE
IS
SELECT *
FROM courses_tbl
WHERE subject = 'Mathematics';
The result set of this cursor will be all columns of course_tb with the subject having ‘Mathematics’.
Cursors in Oracle PLSQL
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 Optimize Media and Entertainment Database Performance with Enteros Database Software, AI-Powered Analytics, and Database Observability
- 30 August 2026
- Database Performance Management
Introduction The media and entertainment industry has become a digital-first business. Streaming services, digital publishing, online gaming content, advertising platforms, social experiences, content management systems, subscription platforms, and personalized recommendations all depend on databases. Modern media companies process enormous volumes of customer, content, advertising, transaction, and behavioral information. Read more”Indian Country” highlights Enteros and its … Continue reading “How to Optimize Media and Entertainment Database Performance with Enteros Database Software, AI-Powered Analytics, and Database Observability”
How to Optimize Manufacturing Database Performance with Enteros Database Software, AIOps, and Predictive Analytics
Introduction Manufacturing is becoming increasingly dependent on digital infrastructure. Modern factories use enterprise resource planning (ERP), manufacturing execution systems (MES), supply-chain platforms, warehouse management systems, industrial IoT, quality management applications, predictive maintenance, and advanced analytics to manage production. Behind these systems are databases processing enormous amounts of operational information. Production schedules, inventory levels, machine data, … Continue reading “How to Optimize Manufacturing Database Performance with Enteros Database Software, AIOps, and Predictive Analytics”
The Future of Industry-Specific Cloud Optimization with AIOps, FinOps, and AI-Powered Database Management
- 28 August 2026
- Database Performance Management
Introduction Cloud computing has become a foundational component of digital transformation across industries. Banking organizations use cloud platforms to support digital payments and online banking. Healthcare providers rely on cloud infrastructure for digital health applications and patient services. Educational institutions operate learning management systems and virtual classrooms in the cloud. Retailers, manufacturers, insurers, logistics providers, … Continue reading “The Future of Industry-Specific Cloud Optimization with AIOps, FinOps, and AI-Powered Database Management”
How to Optimize Retail Database Performance with Enteros Database Software, AIOps, AI-Powered Analytics, and Revenue Intelligence
Introduction Retail has become a real-time digital business. Ecommerce, mobile applications, point-of-sale systems, inventory platforms, loyalty programs, customer analytics, supply chain systems, recommendation engines, and payment platforms all depend on databases. Retailers also experience highly variable demand. Read more”Indian Country” highlights Enteros and its database performance management platform *Black Friday, holiday shopping, product launches, flash … Continue reading “How to Optimize Retail Database Performance with Enteros Database Software, AIOps, AI-Powered Analytics, and Revenue Intelligence”