CREATE OR REPLACE TYPE vcarray AS VARRAY(10) OF VARCHAR2(128); / CREATE TABLE va
ID: 3807922 • Letter: C
Question
CREATE OR REPLACE TYPE vcarray AS VARRAY(10) OF VARCHAR2(128); / CREATE TABLE varray_table (id number primary key, col1 vcarray); INSERT INTO varray_table VALUES (1, vcarray('A')); INSERT INTO varray_table VALUES (2, vcarray('B', 'C')); INSERT INTO varray_table VALUES (3, vcarray('D', 'E', 'F'));
3.1 Write an anonymous block to display the following output: (1.75 point)
ID: 1 There are 1 letters associated with this ID
ID: 2 There are 2 letters associated with this ID
ID: 3 There are 3 letters associated with this ID
Explanation / Answer
DECLARE
CURSOR fcur IS
SELECT id,col1 FROM varray_table;
BEGIN
FOR j IN fcur LOOP
IF j.col1.exists(1) THEN
dbms_output.put_line('ID: '|| j.id || ' There are ' || j.col1.count || ' letters associated with this ID');
END IF;
END LOOP;
END;
/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.