1

我有一个名为 testtransaction 的表,它存储 pervQuestionId 和 NextQuestionId... 如何通过游标在该表中插入记录?有一些东西 cursoe.getnext() ......我如何实现它?我的代码如下所示:

 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;
4

1 回答 1

2

我不想完全写出答案,因为这是家庭作业,你应该做这项工作。游标循环的基本格式之一是:

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

也许这会让你走上正确的轨道。谷歌搜索“Oracle 游标”应该会为您提供数十个有关如何使用游标的示例。

于 2010-01-10T08:19:34.437 回答