Thread: MS SQL Server General Questions/How to use an Oracle Associative Array in a SQL query

How to use an Oracle Associative Array in a SQL query

source


-- Create type

create type v2t as table of varchar2(30);


-- use it in stored procedure

FOR i IN 1..associativeArray.COUNT LOOP

    databaseArray.extend(1);

    databaseArray(i) := associativeArray(i);

END LOOP;

OPEN refCursor FORSELECT T.*

   FROM   SOME_TABLE T,

        ( SELECT COLUMN_VALUE V

         FROM   TABLE( databaseArray )

        ) T2

WHERE  T.NAME = T2.V;






Re: How to use an Oracle Associative Array in a SQL query

SQL> create type MONTH_TYPE is table of varchar2(20);


declare
   month_table   MONTH_TYPE := MONTH_TYPE();
   mon varchar2(20);
 begin
   month_table.extend;
   month_table(1) := 'Jan';
   month_table.extend;
   month_table(2) := 'Feb';

   update some_table
   set x = 1
   where month in (select column_value from table(month_table));
end;