Querying oracle clob column

后端 未结 4 1815
别那么骄傲
别那么骄傲 2021-02-05 03:10

I have a table with a clob column. Searching based on the clob column content needs to be performed. However

select * from aTable where aClobColumn = \'value\';

4条回答
  •  逝去的感伤
    2021-02-05 03:34

    Yes, it's not allowed (this restriction does not affect CLOBs comparison in PL/SQL) to use comparison operators like =, !=, <> and so on in SQL statements, when trying to compare two CLOB columns or CLOB column and a character literal, like you do. To be able to do such comparison in SQL statements, dbms_lob.compare() function can be used.

      select * 
        from aTable 
       where dbms_lob.compare(aClobColumn, 'value') = 0
    

    In the above query, the 'value' literal will be implicitly converted to the CLOB data type. To avoid implicit conversion, the 'value' literal can be explicitly converted to the CLOB data type using TO_CLOB() function and then pass in to the compare() function:

      select * 
        from aTable 
       where dbms_lob.compare(aClobColumn, to_clob('value')) = 0
    

提交回复
热议问题