<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Thu May 23 23:17:35 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-2237/DDC-2237.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-2237] oracle IN statement with more than 1000 values</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2237</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;If I have a query with a IN statement with more tahn 1000 values I get an sql error.&lt;/p&gt;

&lt;p&gt;I&apos;ve try IN with implode:&lt;br/&gt;
select * from test where id IN(&apos; . implode(&apos;,&apos;, $values) . &apos;)&lt;br/&gt;
and I&apos;ve also try with executeQuery:&lt;br/&gt;
select * from test where id IN(:test)&lt;br/&gt;
  executeQuery($sql, array($values), array(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY))&lt;/p&gt;</description>
                <environment></environment>
            <key id="14376">DDC-2237</key>
            <summary>oracle IN statement with more than 1000 values</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/critical.png">Critical</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="mdrolet">Marc Drolet</reporter>
                        <labels>
                    </labels>
                <created>Fri, 11 Jan 2013 16:34:25 +0000</created>
                <updated>Tue, 2 Apr 2013 12:30:05 +0000</updated>
                                    <version>2.2.2</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="19281" author="mdrolet" created="Fri, 11 Jan 2013 16:47:29 +0000"  >&lt;p&gt;Here is the way I&apos;ve implement the solution on my side: (for oracle)&lt;/p&gt;

&lt;p&gt;into Doctrine/DBAL/Statement.php, I&apos;ve add this method:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
/**
     * Binds a parameter value to the statement.
     * This is implemented &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; way &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; oracle only. Other drivers are redirected to bindValue method.
     *
     * The value will be bound with to the type provided (that required to be a table type).
     *
     * @param &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; $name The name or position of the parameter.
     * @param Array $value The value of the parameter.
     * @param &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; $type The name of the type to use to bind.
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;boolean&lt;/span&gt; TRUE on success, FALSE on failure.
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function bindList($name, Array $value, $type)
    {
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (&apos;oracle&apos; !== $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;platform-&amp;gt;getName())
        {
            $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;bindValue($name, $value, $type);
        }
        &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt;
        {
            &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;stmt-&amp;gt;bindList($name, $value, $type);
        }
    }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;into Doctrine/DBAL/Driver/Statement.php I&apos;ve add:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
/**
     * @TODO: docs
     */
    function bindList($param, Array $values, $type);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;into Doctrine/DBAL/Driver/OCI8/OCI8Statement.php I&apos;ve add this method:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
/**
     * {@inheritdoc}
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function bindList($param, Array $value, $type)
    {
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!($list = oci_new_collection($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_dbh, $type)))
        {
            &lt;span class=&quot;code-comment&quot;&gt;//&lt;span class=&quot;code-keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; OCI8Exception::fromErrorInfo($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;errorInfo());
&lt;/span&gt;        }

        foreach ($value as $entry)
        {
            $list-&amp;gt;append($entry);
        }
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!oci_bind_by_name($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sth, $param, $list, -1, OCI_B_NTY))
        {
            &lt;span class=&quot;code-comment&quot;&gt;//&lt;span class=&quot;code-keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; OCI8Exception::fromErrorInfo($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;errorInfo());
&lt;/span&gt;        }
    }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;// NOTE: we should probably add the bindList to all driver Statement object. &lt;/p&gt;

&lt;p&gt;into your code you can use it this way:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
$sql = &quot;
    SELECT *
    FROM test
    WHERE id IN
    (
        SELECT *
        FROM
        (
            CAST (: p_ids AS list_int_type)
        )
    )
&quot;;
$stmt = connection-&amp;gt;prepare($sql);
$stmt-&amp;gt;bindList(&apos;: p_ids&apos;, $ids, &apos;list_int_type&apos;);
$stmt-&amp;gt;execute();
$rs = $stmt-&amp;gt;fetchAll(PDO::FETCH_ASSOC);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;NOTE:&lt;br/&gt;
list_int_type need to be a valid oracle data type. You can create one with the name you want.&lt;br/&gt;
example:&lt;br/&gt;
you can have 2 type of accepted array of values:  integer and string&lt;br/&gt;
let&apos;s say we create one for string named: list_str_type  and one for integer list_int_type&lt;/p&gt;

&lt;p&gt; create or replace type list_str_type as table of varchar2(4000);&lt;br/&gt;
 create or replace type list_int_type as table of number;&lt;/p&gt;</comment>
                    <comment id="19924" author="beberlei" created="Mon, 1 Apr 2013 21:44:51 +0000"  >&lt;p&gt;Hey &lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=mdrolet&quot; class=&quot;user-hover&quot; rel=&quot;mdrolet&quot;&gt;Marc Drolet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;thanks for the feedback and the solution, however i would like to have something generic that is working independent of the database driver. This code is very specific.&lt;/p&gt;

&lt;p&gt;Can you point me to some documentation why oci collection works with more than 1000 elements and how it works in PHP?&lt;/p&gt;</comment>
                    <comment id="19929" author="mdrolet" created="Tue, 2 Apr 2013 12:30:05 +0000"  >&lt;p&gt;Hi Benjamin,&lt;/p&gt;

&lt;p&gt;The limitation is not from the oci driver, it&apos;s an oracle limitation.  There are a couple of possible solution/implementation that can be done but the one I&apos;ve provide is the one that perform better for the test I&apos;ve done and from what I can found over the blogs I&apos;ve read.&lt;/p&gt;

&lt;p&gt;I can&apos;t find the exact documentation of oracle.  oracle doc is so poor. &lt;br/&gt;
Here is the best description link I can provide that describe some possible implementation.&lt;br/&gt;
&lt;a href=&quot;http://vsadilovskiy.wordpress.com/substituting-a-collection-for-in-list-performance-study/&quot; class=&quot;external-link&quot;&gt;http://vsadilovskiy.wordpress.com/substituting-a-collection-for-in-list-performance-study/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I don&apos;t know if there is similar limitation with other database.  With the implementation I&apos;ve provided, It will be possible to implement the proper solution depending on the database limitation you face otherwise it will execute the generic IN. What&apos;s bad, we need to create the type into the database.&lt;/p&gt;

&lt;p&gt;NOTE: In my case, I can not perform a sub-query, I get the my collection from a web service call.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>