Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this a possible Oracle bug or am I missing something?
    primarykey
    data
    text
    <p>Database is Oracle 10.2.0.1.0 - 64bit running on Red Hat Enterprise Linux ES release 4 (Nahant Update 8)</p> <p>In SQL*Plus following code run perfectly:</p> <pre><code>var comment_id number exec :comment_id := 3052753 select e.label as doc_name, e.url, i.item_id, 'multi' as form_type from cr_items i, cr_extlinks e where i.parent_id = :comment_id and e.extlink_id = i.item_id UNION select null as doc_name, utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(r.content, 2000, 1)) as url, r.item_id, 'single' as form_type from cr_revisions r where r.revision_id = content_item.get_latest_revision(:comment_id); / </code></pre> <p>In this case, it returns 2 rows, 1 from each part of the UNION. If I change the call to content_item.get_latest_revision as follows, it breaks as follows:</p> <pre><code>var comment_id number exec :comment_id := 3052753 select e.label as doc_name, e.url, i.item_id, 'multi' as form_type from cr_items i, cr_extlinks e where i.parent_id = :comment_id and e.extlink_id = i.item_id UNION select null as doc_name, utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(r.content, 2000, 1)) as url, r.item_id, 'single' as form_type from cr_revisions r where r.revision_id = ( select content_item.get_latest_revision(:comment_id) from dual); / </code></pre> <p>The error:</p> <pre><code>SQL&gt; where r.revision_id = ( select content_item.get_latest_revision(:comment_id) from dual) * ERROR at line 14: ORA-00904: : invalid identifier </code></pre> <p>Now, what's really crazy about this piece of SQL is that the 2nd example above is the <strong>only</strong> case that breaks. For example, if I take the query in example 2 above and just remove the doc_name field from both sides of the union everything suddenly works again. Or if I remove the utl_raw.cast_to_varchar2 bit, or the union itself (and run each part separately). It's just that precise combination of UNION, AND clauses and function call that breaks. </p> <p>Somebody suggested that it might be bug 6038461, 'Wrong results from SQL with UNION and a fast DUAL subquery', but I don't think that's a good fit.</p> <p>Anyone have a clue what's up with the 2nd query?</p> <p>PS I should add that in TOAD there is no error - the queries run fine...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    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