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

Can a select statement fire a trigger?

1202


How would you pass hints to the sql processor?

1034


what is sql? : Sql dba

1064


What is sqlca in db2?

1030


which command using query analyzer will give you the version of sql server and operating system? : Sql dba

1101


What is a call statement? Explain with an example.

1065


Can we connect to postgresql using sql developer?

1044


How is use pl and sql?

1104


How to run sql commands in sql*plus?

1247


How many types of tables are there?

994


What is the difference between sql and isql*plus?

1156


What is query optimization in sql?

1038


What is the use of function in sql?

1143


What are the three forms of normalization?

1090


List different type of expressions with the example.

965