Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store values fetch by cursor in array or empty cursor.

Status
Not open for further replies.

misterimran

Programmer
May 13, 2002
19
PK
hi friends,
i want to store number of records fetched by a cursor in my pl/sql code for later user in the same program unit.

like i have a cursor that fetch the following records for the columns
Employee_ID, Ded_ID, Ded_Date, Ded_Amount
14210, 1, 12-Mar-03, 200
14210, 1, 14-Mar-03, 400
10060, 2, 18-Mar-03, 2100

Now i want to store these records in my PL/Sql Code like for example in
an array or in an emptry cursor. What shall i do? how can we store records fetch by the cursor in any kind of variables?

Plis help with example.
Best Regards,
Imran Baig
 
You may use some collection type. The most common (works since Oracle 7 at least) is INDEX BY table. You may define a type and then a variable of that type. Let's
suppose that your cursor is called cEmps.

declare
...

type tEmps is table of cEmps%rowtype index by binary_integer;

mEmps tEmps;
i integer :=0;
begin
for f in cEmps loop
i := i + 1;
mEmps(i) := f;
end loop;
end;

In more recent releases you may also consider BULK COLLECT.


Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top