Oracle Error “inconsistent datatypes: expected CHAR got LONG”

后端 未结 2 663
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 01:22

I\'m trying to run the following query to find views containing a given keyword:

select  *
from    ALL_VIEWS
where   OWNER = \'SALESDBA\'
        and TEXT li         


        
2条回答
  •  迷失自我
    2021-01-18 02:03

    Your problem is that TEXT is of type LONG - although Oracle deprecated this type a long, long time ago, they're still using it in their own views :-(

    To convert a LONG to a (searchable) CLOB, you can use the TO_LOB() function (see Oracle documentation for TO_LOB().

    Unfortunately, this doesn't work for simple SELECT statements. You'll have to create an intermediary table:

    create table search_all_views as 
    select  av.owner, av.view_name, to_lob(text) as text_clob
    from    ALL_VIEWS av;
    

    Then, you can search using that table:

    select * 
    from search_all_views
    where text_clob like '%rownum%';
    

提交回复
热议问题