top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is Cursor ? Explain With Example?

0 votes
78 views
What is Cursor ? Explain With Example?
posted Dec 4, 2014 by Amer

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

In Oracle, a cursor is a mechanism by which you can assign a name to a SELECT statement and manipulate the information within that SQL statement.

EXAMPLE

Here is an example of a function that uses a CURSOR FOR LOOP:

CREATE OR REPLACE Function TotalIncome
( name_in IN varchar2 )
RETURN varchar2
IS
total_val number(6);

cursor c1 is
SELECT monthly_income
FROM employees
WHERE name = name_in;

BEGIN

total_val := 0;

FOR employee_rec in c1
LOOP
total_val := total_val + employee_rec.monthly_income;
END LOOP;

RETURN total_val;

END;

answer Dec 5, 2014 by Arun Gowda
Similar Questions
+3 votes

In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the %NOTFOUND cursor variable in the exit when statement? Why?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...