Hey . I'm learning to work with Index-by tables.

DECLARE TYPE population_type IS TABLE OF NUMBER INDEX BY VARCHAR2(64); country_population population_type; howmany NUMBER; status NUMBER; BEGIN country_population('Greenland') := 100000; -- Creates new entry country_population('MILAN') := 3000; howmany := country_population('Greenland'); status := country_population('MILAN'); END; / 

Created an array of data and pass it to peppers. I get an error

Bind Variable "howmany" is not declared.

when calling the code:

  SELECT :howmany from dual; 

How to transfer a value to a variable and get it?

    1 answer 1

    Here you have the variables pl / sql and the variables Sql * Plus confused.

    First you declare howmany variable as pl / sql variable and then try to use it as Sql * Plus variable.

    So that it can be used this way, you need to declare it differently:

     variable howmany number; DECLARE TYPE population_type IS TABLE OF NUMBER INDEX BY VARCHAR2(64); country_population population_type; status NUMBER; BEGIN country_population('Greenland') := 100000; -- Creates new entry country_population('MILAN') := 3000; :howmany := country_population('Greenland'); status := country_population('MILAN'); END; / select :howmany from dual /