Can you pass a parameter to a cursor?

Can you pass a parameter to a cursor?

- PL/SQL also allows you to pass parameters into cursors. It eases your work because:
1. A parameter makes the cursor more reusable.
2. A parameter avoids scoping problems.

- However, you should pass parameters when you are going to use it at more then one place and when there are going to be different values for the same WHERE statement.

Parameterized cursor:

/*Create a table*/
create table Employee
First_Name VARCHAR2(10 BYTE)

/*Insert some data*/
Insert into Employee (ID, First_Name) values ('01','Harry');

/*create cursor*/
cursor c_emp(cin_No NUMBER)is select count(*) from employee where id=cin_No;
v_countEmp NUMBER;
open c_emp (v_deptNo);
fetch c_emp into v_countEmp;
close c_emp;

/*Using cursor*/
Open c_emp (10);
Functioning of CURSOR FOR LOOP with example
A Cursor is a PL/SQL construct and accesses the stored information in a named work area.....
Define Simple/Explicit , Parametric and Internal/Implicit cursor
Implicit: queries that return only one row. Explicit: can be declared by us for the queries that return more than one row..
What is an SQL *FORMS?
Oracle Forms is part of Oracle's Internet Developer Suite. Its earlier versions were called SQL*Forms....
Post your comment