Re: SELECT Question

From: yossarian <yossarian99_at_operamail.com>
Date: Wed, 18 Jun 2008 10:15:22 +0200
Message-ID: <4858c41a$0$17949$5fc30a8@news.tiscali.it>


Mtek wrote:

> Quick question here, if I have a WHERE clause with an IN condition -
> WHERE var IN (1, 2, 3)......
>
> What if the list is dynamic? How would you do that?

Something along the lines of:

SQL> create type ListType as table of number ;   2 /

SQL> declare
  2 ids ListType := ListType() ;
  3 names owa_text.vc_arr ;
  4 begin

  5    ids.extend(3) ;
  6    ids(1) := 102 ;
  7    ids(2) := 104 ;
  8    ids(3) := 110 ;
  9    select
 10      LAST_NAME
 11    bulk collect into
 12      names
 13    from
 14      table(cast(ids as ListType)) ids,
 15      employees                    emp
 16    where
 17      emp.employee_id = ids.column_value
 18 ;
 19* end ;
 20 /

PL/SQL procedure successfully completed.

Y. Received on Wed Jun 18 2008 - 03:15:22 CDT

Original text of this message