开发者

How to get next and previous record from cursor?

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;


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜