Question

How to INSERT values into map?

CREATE OR REPLACE PROCEDURE ZC_FILL_WNIOSKI IS
  TYPE MAP_ARRAY IS TABLE OF NUMBER INDEX BY VARCHAR2(30);
  WNIOSKI_MAP MAP_ARRAY;
  BEGIN

  INSERT INTO WNIOSKI_MAP
     SELECT ID_WNIOSEK_ORG, ID_WNIOSEK FROM ZC_WNIOSKI;
  ...

Current version gives me the following error:

PL/SQL: ORA-00942 in line with INSERT.
Was it helpful?

Solution

You don't INSERT into PL/SQL collections like this.

You could do a BULK COLLECT from the table into your collection but then you could only be selecting one column from the table. Assuming your intention is to select the key and the value, you can do something like (assuming I've guessed which column is the character key and which is the numeric value)

FOR i IN (SELECT ID_WNIOSEK_ORG, ID_WNIOSEK FROM ZC_WNIOSKI)
LOOP
  WNIOSKI_MAP( i.ID_WNIOSEK_ORG ) := ID_WNIOSEK;
END LOOP;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top