oracle – ORA-00932:不一致数据类型:expected – 获取CLOB

考虑到TEST_SCRIPT是一个CLOB为什么当我在Oracle上从SQL * PLUS运行这个简单的查询时,我得到错误:

ORA-00932: inconsistent datatypes: expected - got CLOB

我已经阅读了很多关于同样的错误的问题,但没有一个运行从SQLPLUS直接查询

    UPDATE IMS_TEST 
       SET TEST_Category  = 'just testing'  
     WHERE TEST_SCRIPT    = 'something'
       AND ID             = '10000239' 

完整示例:

SQL> create table ims_test(
  2  test_category varchar2(30),
  3  test_script clob,
  4  id varchar2(30)
  5  );

Table created.

SQL> insert into ims_test values ('test1','something','10000239');

1 row created.

SQL> UPDATE IMS_TEST
  2  SET TEST_Category  = 'just testing'
  3  WHERE TEST_SCRIPT    = 'something'
  4  AND ID             = '10000239';
WHERE TEST_SCRIPT    = 'something'
      *
ERROR at line 3:
ORA-00932: inconsistent datatypes: expected - got CLOB
您不能将CLOB放在WHERE子句中。从documentation

Large objects (LOBs) are not supported in comparison conditions.
However, you can use PL/SQL programs for comparisons on CLOB data.

如果您的值总是小于4k,您可以使用:

UPDATE IMS_TEST 
   SET TEST_Category           = 'just testing'  
 WHERE to_char(TEST_SCRIPT)    = 'something'
   AND ID                      = '10000239';

奇怪的是,通过CLOB搜索。你能不能只是通过ID列搜索?

http://stackoverflow.com/questions/12980038/ora-00932-inconsistent-datatypes-expected-got-clob

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:oracle – ORA-00932:不一致数据类型:expected – 获取CLOB