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

前端之家收集整理的这篇文章主要介绍了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列搜索

原文链接:https://www.f2er.com/oracle/206968.html

猜你在找的Oracle相关文章