Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not going to work this way, because Oracle won't recognize that you're actually trying to pass in a list of possible values.</p> <p>What you want is a query like</p> <pre><code>select * from t where x in (1,2,3) </code></pre> <p>but what your code does is</p> <pre><code>select * from t where x = '1,2,3' </code></pre> <p>As x is numeric, Oracle tries to cast '1,2,3' into a number - and fails...</p> <p>Please refer to this <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11%3a%3a%3a%3a%3aP11_QUESTION_ID:210612357425" rel="nofollow">excellent thread at AskTom</a> for correct solutions (and a sermon about the importance of bind variables).</p> <p><strong>Update:</strong> Tom's first answer already contains everything you need, but it used the now obsolete <code>THE</code> keyword instead of <code>TABLE</code>. So here are the steps that should work for you:</p> <p>first create a type for a collection of numbers</p> <pre><code>create or replace type TableOfNumber as table of number; </code></pre> <p>then create a function that splits your string and returns your newly created collection</p> <pre><code>create or replace function in_list( p_string in varchar2 ) return TableOfNumber as l_string long default p_string || ','; l_data TableOfNumber := TableOfNumber(); n number; begin loop exit when l_string is null; n := instr( l_string, ',' ); l_data.extend; l_data(l_data.count) := to_number( substr( l_string, 1, n-1 ) ); l_string := substr( l_string, n+1 ); end loop; return l_data; end; </code></pre> <p>Now you can use this function in a query:</p> <pre><code>SELECT ... FROM ... WHERE c.cluster_cd IN (select * from TABLE (select cast(in_list(:paramClusterCD) as mytableType) from dual)) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload