oracle - PL/SQL - How to use an array in an IN Clause -


i'm trying use array of input values procedure in in clause part of clause of cursor. know has been asked before, haven't seen how make syntax compile correctly.

in package specification, type

type t_brth_dt table of sourcetable.stdt_brth_dt%type index pls_integer; 

sourcetable.std_brth_dt date column in table.

simplified version of cursor in package body -

 cursor datacursor_sort( p_brth_dt in t_brth_dt)     select *       sourcetable       a.brth_dt in (select column_value                             table(p_brth_dt)) 

when try compile this, i'm getting following errors.

  • [1]:(error): pls-00382: expression of wrong type
  • [2]:(error): pl/sql: ora-22905: cannot access rows non-nested table item

i know looks similar other questions, don't understand syntax error is.

in order use collection defined nested table or associative array in from clause of query either should, @alex poole correctly pointed out, create schema level (sql) type or use one, available trough odciconst package - odcidatelist intend use list of dates. example, cursor definition might this:

cursor datacursor_sort(p_brth_dt in sys.odcidatelist)   select *     sourcetable     a.brth_dt in (select column_value                           table(p_brth_dt)) 

or

cursor datacursor_sort(p_brth_dt in sys.odcidatelist)   select s.*     sourcetable      s     join table(p_brth_dt) t       on (t.brth_dt = s.column_value) 

note: should take consideration time part of date when performing date comparison. if want compare date part useful rid of time part using trunc() function.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -