Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is string join?

969


Can there be more than one function with a similar name in a pl/sql block?

974


Why do we use function in pl sql?

1052


how to see the create table statement of an existing table? : Sql dba

994


What is sql partition?

1095


How do you exit in sql?

1100


what is the difference between a local and a global temporary table? : Sql dba

1058


How can we implement rollback or commit statement in a trigger?

1022


Explain autonomous transaction.

1152


What is a pdo connection?

1018


In pl/sql, what is bulk binding, and when/how would it help performance?

985


How do I run sql profiler?

1059


How do I clear the screen in sql plus?

1035


Why do we use view in sql?

941


What is a dirty read sql?

1119