pl/sql-record
DECLARE
CURSOR course_cur IS
SELECT *
FROM course
WHERE rownum <= 4;
TYPE course_type IS RECORD
(course_no NUMBER(38),
description VARCHAR2(50),
cost NUMBER(9,2),
prerequisite NUMBER(8),
created_by VARCHAR2(30),
created_date DATE,
modified_by VARCHAR2(30),
modified_date DATE);
course_rec1 course%ROWTYPE; -- table-based record
course_rec2 course_cur%ROWTYPE; -- cursor-based record
course_rec3 course_type; -- user-defined record
BEGIN
-- Populate table-based record
SELECT *
INTO course_rec1
FROM course
WHERE course_no = 10;
-- Populate cursor-based record
OPEN course_cur;
LOOP
FETCH course_cur INTO course_rec2;
EXIT WHEN course_cur%NOTFOUND;
END LOOP;
course_rec1 := course_rec2;
course_rec3 := course_rec2;
END;
CURSOR course_cur IS
SELECT *
FROM course
WHERE rownum <= 4;
TYPE course_type IS RECORD
(course_no NUMBER(38),
description VARCHAR2(50),
cost NUMBER(9,2),
prerequisite NUMBER(8),
created_by VARCHAR2(30),
created_date DATE,
modified_by VARCHAR2(30),
modified_date DATE);
course_rec1 course%ROWTYPE; -- table-based record
course_rec2 course_cur%ROWTYPE; -- cursor-based record
course_rec3 course_type; -- user-defined record
BEGIN
-- Populate table-based record
SELECT *
INTO course_rec1
FROM course
WHERE course_no = 10;
-- Populate cursor-based record
OPEN course_cur;
LOOP
FETCH course_cur INTO course_rec2;
EXIT WHEN course_cur%NOTFOUND;
END LOOP;
course_rec1 := course_rec2;
course_rec3 := course_rec2;
END;