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
What happens in oracle commit?
Explain oracle insert into command?
What are advantages of dateset in datastage?
What is ASM (Automatic Storage Management) in Oracle?
How do I use unicode codesets with the weblogic jdriver for oracle driver?
Whether any commands are used for months calculation? If so, what are they?
What privilege is needed for a user to delete rows from tables in another schema?
Explain the use of inctype option in exp command.
Can we call procedure inside function in oracle?
What is a sub query? What are its various types?
What are the limitations of check constraint?
Can sub procedure/function be called recursively?
How to concatenate two text values in oracle?
How to write text literals in oracle?
What is an Oracle index?