What is cursor

Answer Posted / ramdeep garg

A cursor is a SELECT statement that is defined within the
declaration section of your PLSQL code. We'll take a look
at three different syntaxes for cursors.

Cursor without parameters (simplest)
The basic syntax for a cursor without parameters is:

CURSOR cursor_name
IS
SELECT_statement;



For example, you could define a cursor called c1 as below.

CURSOR c1
IS
SELECT course_number
from courses_tbl
where course_name = name_in;

The result set of this cursor is all course_numbers whose
course_name matches the variable called name_in.



Below is a 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;

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is null value in oracle?

837


How to turn on or off recycle bin for the instance?

833


What is an Oracle Instance?

886


What are the attributes of the cursor?

769


If youre unsure in which script a sys or system-owned object is created, but you know its in a script from a specific directory, what UNIX command from that directory structure can you run to find your answer?

1872


What are the restrictions in a oracle read only transaction?

777


What are the varoius components of physical database structure of oracle database?

764


How to count duplicated values in a column in oracle?

785


What is the difference between hot backup and cold backup in oracle? Tell about their benefits also.

756


What is the difference between online and offline backups?

750


Is oracle the best database?

715


What is transaction control statement and how many types of transaction control statement in Oracle?

818


How to manage transaction isolation level?

762


Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).

2048


Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.

1906