4. Use PL/SQL cursor to retrieve all CourseId and Title from the COURSE table. Create two VARRAYs to hold CourseId and Title values respectively. Add elements to both varrays and assign values retrieved into cursor. Display values from both varrays.

What will be an ideal response?


```
SQL> DECLARE
2 CURSOR course_cur IS
3 SELECT CourseId, Title FROM course;
4 TYPE id_varray_type IS VARRAY(10) OF course.CourseId%TYPE;
5 id_varray id_varray_type := id_varray_type();
6 TYPE title_varray_type IS VARRAY(10) OF course.Title%TYPE;
7 title_varray title_varray_type := title_varray_type();
8 c NUMBER(2) := 1;
9 BEGIN
10 FOR course_rec IN course_cur LOOP
11 id_varray.EXTEND;
12 id_varray(c) := course_rec.CourseId;
13 title_varray.EXTEND;
14 title_varray(c) := course_rec.Title;
15 DBMS_OUTPUT.PUT
16 ('CourseId: ' || id_varray(c));
17 DBMS_OUTPUT.PUT_LINE
18 (' Title : ' || title_varray(c));
19 c := c + 1;
20 END LOOP;
21 END;
22 /
CourseId: EN100 Title : Basic English
CourseId: LA123 Title : English Literature
CourseId: CIS253 Title : Database Systems
CourseId: CIS265 Title : Systems Analysis
CourseId: MA150 Title : College Algebra
CourseId: AC101 Title : Accounting

PL/SQL procedure successfully completed.
```

Computer Science & Information Technology

You might also like to view...

Referring to the accompanying figure, which callout points to the option used to add sound to an animation?

A. E B. F C. G D. H

Computer Science & Information Technology

An analysis of the income and expense for each month is called a break-even analysis

Indicate whether the statement is true or false

Computer Science & Information Technology

When you ____ an image, you transfer it from the Internet to your computer.

A. tweet B. download C. compress D. none of the above

Computer Science & Information Technology

Database functions do not require a Criteria Range.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology