views:

91

answers:

1

Hi... I have a table named testtransaction which stores pervQuestionId and NextQuestionId... How to insert records in this table through cursor? there is something cursoe.getnext()...how do i implement it? My code is shown below:

 create or replace function store_data(disciplineid in char,
                                       NoOfQuestions in number)
  is
  cur_out sys_refcursor;
 begin         
     open cur_out for
     select getguid() tmp,
     QuestionNo,Disciplineid
     from tbliffcoQuestionmaster
     where (DisciplineId=discipline1 AND  rownum <= disc1_NoOfQuestions)
     order by tmp ;
 ///now it should insert records.
end;
+2  A: 

I don't want to completely write the answer since it's homework and you're supposed to be doing the work. One of the basic formats of a cursor loop is:

LOOP
   FETCH cursor INTO x;
   EXIT WHEN cursor%NOTFOUND;
   --do something
END LOOP;

Maybe that will get you on the right track. Googling for "Oracle cursor" should get you dozens of examples of how cursors are used.

Wade Williams