Oracle
 sql >> Base de données >  >> RDS >> Oracle

Est-ce un bogue Oracle possible ou ai-je raté quelque chose?

Pas un grand fan de AND/WHERE column = (SELECT column....) , globalement, il vaut mieux écrire AND/WHERE column IN (SELECT column...) . Mais dans votre cas, il ne semble pas y avoir de possibilité de plusieurs lignes ou colonnes dans la sous-requête. Que diriez-vous-

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 IN ( select content_item.get_latest_revision(:comment_id) 
                          from dual);

/

OU

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 EXISTS (select 'x'
                   from dual
                    where content_item.get_latest_revision(:comment_id) =r.revision_id);


/