Write a simple program on cursors

Answer Posted / subhendu

CREATE OR REPLACE Function test( I_name IN varchar2 )
RETURN number
IS

CURSOR c1
IS
SELECT course_number,
instructor
from courses_tbl
where course_name = I_name
FOR UPDATE of instructor;

v_number courses_tbl.course_number%type;
v_instructor courses_tbl.instructor%type;

BEGIN

open c1;
fetch c1 into v_number,v_instructor ;

if c1%found then

UPDATE courses_tbl
SET instructor = 'SMITH'
WHERE CURRENT OF c1;

COMMIT;

end if;
close c1;
RETURN v_number;

END;

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you modify a trigger?

520


What is triggering circuit?

588


What are the different types of constraints?

556


how many ways we can we find the current date using mysql? : Sql dba

605


What are triggers and its uses?

587






What is dense_rank in sql?

534


What are different methods to trace the pl/sql code?

532


Why is a trigger used?

519


What are the types of triggers in sql?

489


Can you selectively load only those records that you need? : aql loader

605


How do you create an update query?

515


Explain the update statement in sql

556


What is having clause in sql?

520


What is %rowtype in pl sql?

509


What is trigger in pl sql with examples?

511