Oracle PL/SQL - How to create a simple array variable?

后端 未结 5 1315
自闭症患者
自闭症患者 2020-11-29 16:06

I\'d like to create an in-memory array variable that can be used in my PL/SQL code. I can\'t find any collections in Oracle PL/SQL that uses pure memory, they all seem to b

5条回答
  •  长情又很酷
    2020-11-29 16:41

    Sample programs as follows and provided on link also https://oracle-concepts-learning.blogspot.com/

    plsql table or associated array.

            DECLARE 
                TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20); 
                salary_list salary; 
                name VARCHAR2(20); 
            BEGIN 
               -- adding elements to the table 
               salary_list('Rajnish') := 62000; salary_list('Minakshi') := 75000; 
               salary_list('Martin') := 100000; salary_list('James') := 78000; 
               -- printing the table name := salary_list.FIRST; WHILE name IS NOT null 
                LOOP 
                   dbms_output.put_line ('Salary of ' || name || ' is ' || 
                   TO_CHAR(salary_list(name))); 
                   name := salary_list.NEXT(name); 
                END LOOP; 
            END; 
            /
    

提交回复
热议问题