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
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.
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.
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.
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."
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With