Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA-00932: inconsistent datatypes: expected - got CLOB

Tags:

oracle

clob

Considering that TEST_SCRIPT is a CLOB why when I run this simple query from SQL*PLUS on Oracle, I get the error:

ORA-00932: inconsistent datatypes: expected - got CLOB 

I have been reading a lot of questions about the same error but none of those is running a direct query from SQLPLUS

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

Full example:

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 
like image 428
user1298925 Avatar asked Oct 19 '12 18:10

user1298925


People also ask

How do I fix Ora 00932?

To correct this error, you can do one of the following: Not use Oracle functions in your SQL (against the LONG datatype field). Consider modifying your table so that the supplier_name field is either a VARCHAR2 or CHAR field. Try writing a custom PLSQL function to convert a LONG to a VARCHAR2.

What is CLOB datatype?

The CLOB data type stores any kind of text data in random-access chunks, called sbspaces. Text data can include text-formatting information, if this information is also textual, such as PostScript, Hypertext Markup Language (HTML), Standard Graphic Markup Language (SGML), or Extensible Markup Language (XML) data.

What is CLOB datatype in Oracle with example?

A CLOB (character large object) value can be up to 2,147,483,647 characters long. A CLOB is used to store unicode character-based data, such as large documents in any character set.

How do you use CLOB in Group by clause?

You cannot specify LOB columns in the ORDER BY clause of a query, or in the GROUP BY clause of a query or in an aggregate function. To get around this you can to_char the column if it's < 4000 characters and substr it if it's longer. "there is no reason for it to be present in the GROUP BY list."


1 Answers

You can't put a CLOB in the WHERE clause. From the documentation:

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

If your values are always less than 4k, you can use:

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

It is strange to search by a CLOB anyways.. could you not just search by the ID column?

like image 99
Craig Avatar answered Sep 19 '22 11:09

Craig