Question: My PL/SQL code is giving me an error. Here is the code: /***************************************************************************** Assignment A new RATING_AGENCY tablele and RATING_AGENCY_S sequence that starts with a

My PL/SQL code is giving me an error. Here is the code:

/*****************************************************************************

Assignment

A new RATING_AGENCY tablele and RATING_AGENCY_S sequence that starts with a value of 1001.

Add a new RATING_AGENCY_ID column to the ITEM tablele.

A SQL structure or composite object type, as qualified above.

A SQL collection, as a tablele of the composite object type.

An anonymous block PL/SQL program that:

Declare a local cursor to read the contents of the RATING_AGENCY tablele.

A cursor for loop that reads the cursor contents and assigns them to a local variable of the SQL collection data type.

A range for loop that reads the collection contents and updates the RATING_AGENCY_ID column in the item tablele by checking

the ITEM_RATING and ITEM_RATING_AGENCY column values with the members of the collections composite object type.

*****************************************************************************/

-- Open your log file and make sure the extension is ".txt".

SPOOL lab5.txt

/* Show the output */

SET SERVEROUTPUT ON SIZE UNLIMITED

SET VERIFY OFF;

CLEAR SCREEN;

-- Drop pre-existing object type.

DROP TYPE rating_agency;

-- Creates an object type.

CREATE OR REPLACE

TYPE rating_agency IS OBJECT

( rating_agency_id NUMBER

, rating VARCHAR2(8)

, rating_agency VARCHAR2(4));

/

-- Drop pre-existing table and re-create it

DROP TABLE rating_agency_table;

CREATE TABLE rating_agency_table

( rating_agency_id NUMBER

, rating VARCHAR2(8)

, rating_agency VARCHAR2(4));

-- Add a RATING_AGENCY_S sequence that starts with a value of 1001.

CREATE SEQUENCE rating_agency_s

START WITH 1001

INCREMENT BY 1;

DECLARE

-- Create a cursor.

CURSOR c IS

SELECT a.rating_agency_id AS id

, a.rating AS rating

, a.rating_agency AS agency

FROM rating_agency_table a;

--Create a collection of rating_agency

lv_rating_agency_tab rating_agency_table := rating_agency_table();

BEGIN

FOR i IN c LOOP

lv_rating_agency_tab.EXTEND;

lv_rating_agency_tab := rating_agency( rating_agency_id => i.rating_agency_id

, rating => i.rating

, rating_agency => i.rating_agency );

END LOOP;

FOR j IN 1 .. lv_rating_agency_tab(j).COUNT LOOP

INSERT INTO index

( rating_agency_id

, item_rating

, item_rating_agency )

VALUES

( lv_rating_agency_tab.rating_agency_id

, lv_rating_agency_tab.rating

, lv_rating_agency_tab.rating_agency );

END LOOP;

END;

/

SET PAGESIZE 999

COL rating_agency_id FORMAT A24

COL rating FORMAT A14

COL rating_agency FORMAT A12

SELECT * FROM rating_agency_table;

SPOOL OFF

I get the following error:

lv_rating_agency_tab rating_agency_table := rating_agency_table();

*

ERROR at line 10:

ORA-06550: line 10, column 22:

PLS-00488: 'RATING_AGENCY_TABLE' must be a type

ORA-06550: line 10, column 22:

PL/SQL: Item ignored

ORA-06550: line 13, column 1:

PLS-00320: the declaration of the type of this expression is incomplete or

malformed

ORA-06550: line 13, column 1:

PL/SQL: Statement ignored

ORA-06550: line 14, column 1:

PLS-00320: the declaration of the type of this expression is incomplete or

malformed

ORA-06550: line 14, column 1:

PL/SQL: Statement ignored

ORA-06550: line 19, column 15:

PLS-00320: the declaration of the type of this expression is incomplete or

malformed

ORA-06550: line 19, column 1:

PL/SQL: Statement ignored

What does that mean? How do I fix my code?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!