InterviewSolution
Saved Bookmarks
| 1. |
What are Cursor-based records in PL/SQL? |
|
Answer» In PL/SQL, use the %ROWTYPE ATTRIBUTE with an explicit cursor or cursor variable where each field corresponds to a column in the cursor SELECT statement. The following is an example: DECLARE CURSOR cur_dept is SELECT deptid, deptname, deptloc FROM deptbudget; rec_dept cur_dept %rowtype; BEGIN OPEN cur_dept ; LOOP FETCH cur_dept into rec_dept; EXIT WHEN cur_dept %notfound; DBMS_OUTPUT.put_line(rec_dept.deptid || ' ' || rec_dept.deptname || ' ' || rec_dept.deptloc); END LOOP; END; /The output: 1 Finance NORTH 2 Marketing EAST 3 Operations WEST 4 Technical SOUTH 5 Accounting NORTHWEST PL/SQL PROCEDURE successfully completed. |
|