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 the difference between a local and a global temporary table? : Sql dba

1073


how would concatenate strings in mysql? : Sql dba

1093


What is an oracle stored procedure?

1050


What plvcmt and plvrb does in pl/sql?

1319


How do you run a query?

989


What is union and union all keyword in sql?

1040


What is over () in sql?

957


what is blob? : Sql dba

1148


What are the built in functions of sql?

1030


What is crud sql?

982


Can you have a foreign key without a primary key?

953


Why truncate is faster than delete?

1109


What is trigger explain with example?

1037


Why trigger is used in sql?

970


Can instead of triggers be used to fire once for each statement on a view?

962