[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Cursor Used with LOOP/WHILE/REPEAT

Posted on 2012-09-20
Medium Priority
Last Modified: 2012-10-01
I read as folows but not clear on this

Cursor Used with LOOP/WHILE/REPEAT to process a
collection of records (Result set) returned by

Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
Question by:gudii9
LVL 78

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 668 total points
ID: 38420088
There are a ton of examples out there on cursor loops and a couple ways to declare a cursor (explicit or implicit).

The online docs have many examples:  Example 6-6 FETCH Statements Inside LOOP Statements

A list of cursor examples:

If this isn't clear just post back and we can explain it in more detail.
LVL 16

Assisted Solution

by:Swadhin Ray
Swadhin Ray earned 664 total points
ID: 38422960

Accepted Solution

brijesh_chauhan earned 668 total points
ID: 38424539

Curosor Is Nothing But The Pointer To The Dataset.. That Will Intially Pointing To The First Record.

To Use Cursor You Have To Follow These Many Steps.
1. Declare Cursor
2. Open Cursor
3. Fetch Cursor
4. Close Cursor

Here Is Simple  Demo.

Declare curse-name (Eg cur1) CURSOR select query(Eg select id,name from table);

open cur1;

fetch cur1 into a,b; (a and b are temporary variables)

Now What Happens suppose that ur select query has 100 records.
so these 100 recoreds are right now stored in a and b. (id in a AND name in b).

now you can process these records individually by the repeat or any other loops.

this is the main use of the cursor
once this will done close the cursor with

close cur1;

Hope This Would Help.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question