CLOB data type comparison in where clause in Oracle
Error: while comparing the CLOB data type with the CLOB data type I got the following error
create table json_test ( id number, data clob );
create table json_test2 ( id2 number, data2 clob);
SQL> select * from json_test a, json_test2 b where a.data = b.data2;
select * from json_test a, json_test2 b where a.data = b.data2
*
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected - got CLOB
Solution: We need to convert the CLOB datatype to the character before using the CLOB comparison:
select * from json_test a, json_test2 b where to_char(a.data) = to_char(b.data2);