Home > other >  Attempt to assign item to nested table cause PLS-00382: expression is of wrong type. PLSQL
Attempt to assign item to nested table cause PLS-00382: expression is of wrong type. PLSQL

Time:05-11

I have created nested table and I would like to assign item for them. But when I try do this I get an error

Error at line 27, 28: PLS-00382: expression is of wrong type

And 27, 28 line is with the assign. I have declared a few parameters:

DECLARE
    clubIdFirst NUMBER;
    clubIdSecond NUMBER;

    TYPE clubsIdsArray IS TABLE OF NUMBER;
    nestedclubsIdsArray clubsIdsArray:=clubsIdsArray()

BEGIN
   //assign values to clubIdFirst and clubIdSecond trying assign them to table
   nestedclubsIdsArray .EXTEND(2);
   nestedclubsIdsArray := clubIdFirst;
   nestedclubsIdsArray := clubIdSecond;

Why it takes place?

CodePudding user response:

You forgot to say which element you're assigning the value to (see lines #11 and 12), e.g.:

SQL> DECLARE
  2      clubIdFirst NUMBER;
  3      clubIdSecond NUMBER;
  4
  5      TYPE clubsIdsArray IS TABLE OF NUMBER;
  6      nestedclubsIdsArray clubsIdsArray:=clubsIdsArray();
  7
  8  BEGIN
  9     --assign values to clubIdFirst and clubIdSecond trying assign them to table
 10     nestedclubsIdsArray .EXTEND(2);
 11     nestedclubsIdsArray (1):= clubIdFirst;
 12     nestedclubsIdsArray (2):= clubIdSecond;
 13  end;
 14  /

PL/SQL procedure successfully completed.

SQL>
  • Related