Question

Here's my setup:

CREATE TABLE CUSTOMER 
(
  CUSTOMER_ID NUMBER(9, 0) NOT NULL 
, CUSTOMER_NAME VARCHAR2(61 BYTE)
);

CREATE INDEX CTXCAT_CUSTOMER_NAME 
    ON CUSTOMER (CUSTOMER_NAME) INDEXTYPE IS CTXSYS.CTXCAT;

My (simplified) query:

select /*+ INDEX(customer CTXCAT_CUSTOMER_NAME)*/* 
from customer
where CATSEARCH(customer_name,'ltd Anderson',null) > 0 or customer_id > 100

Error:

Error starting at line 1 in command: select /*+ INDEX(customer CTXCAT_CUSTOMER_NAME)/ from customer where CATSEARCH(customer_name,'ltd Anderson',null) > 0 or customer_id > 100 Error report: SQL Error: ORA-20000: Oracle Text error: DRG-10849: catsearch does not support functional invocation 20000. 00000 - "%s" *Cause: The stored procedure 'raise_application_error' was called which causes this error to be generated. *Action: Correct the problem as described in the error message or contact the application administrator or DBA for more information.

The HINT suggestion came from here: https://forums.oracle.com/message/2847094 and clearly doesn't work for me.

Any ideas how to resolve?

Was it helpful?

Solution

The problem is that most probably in your query Oracle uses CATSEARCH as a function invocation, rather than using your index. This is because you have the OR condition and Oracle has to check every row in your table. That's also the reason why HINT won't help. Can you show us the execution plan?

Perhaps try this:

select * 
from customer
where customer_id > 100
UNION
select /*+ INDEX(customer CTXCAT_CUSTOMER_NAME)*/ *
from customer
where CATSEARCH(customer_name,'ltd Anderson',null) > 0;

(the hint shouldn't be necessary in above example)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top