2010-01-10 2 views
1

pervQuestionId 및 NextQuestionId를 저장하는 testtransaction이라는 테이블이 있습니다. 커서를 통해이 테이블에 레코드를 삽입하는 방법은 무엇입니까? 거기에 뭔가가 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; 
+1

형식을 확인하고 '숙제'인 경우 태그를 지정하십시오. –

답변

2

나는 그것이 숙제 그리고 당신이 일을 할 거 야하기 때문에 완전히 답을 쓰고 싶지 않아. 커서 루프의 기본 형식 중 하나는 다음과 같습니다.

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

아마도 올바른 트랙을 얻을 수 있습니다. "오라클 커서"를 검색하면 커서를 사용하는 방법에 대한 수십 가지 예제를 얻을 수 있습니다.

관련 문제