Cursor based record is a record whose structure is drawn from the SELECT list of the cursor. The %ROWTYPE is used to declare the table record also used to declare a record for an explicit declare cursor. Check the below example
DECLARE
/*Define the cursor*/
CURSOR emp_details_cursor
IS
SELECT * from emp;
/*Create a record for this cursor*/
emp_details_rec emp_details_cursor;
BEGIN
OPEN emp_details_cursor;
LOOP
FETCH emp_details_cursor INTO emp_details_rec ;
EXIT WHEN emp_details_rec%NOTFOUND;
/*write your logic*/
END LOOP;
CLOSE emp_details_rec ;
END;
DECLARE
/*Define the cursor*/
CURSOR emp_details_cursor
IS
SELECT * from emp;
/*Create a record for this cursor*/
emp_details_rec emp_details_cursor;
BEGIN
OPEN emp_details_cursor;
LOOP
FETCH emp_details_cursor INTO emp_details_rec ;
EXIT WHEN emp_details_rec%NOTFOUND;
/*write your logic*/
END LOOP;
CLOSE emp_details_rec ;
END;
No comments:
Post a Comment