Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle Text CONTAINS with NULL input string

Chintan GandhiAug 4 2016 — edited Aug 9 2016

Hi,

I am on Oracle 11gR2. I have a table where I have created a text index.

I have written a query as below:

SELECT *

  FROM my_transactions t

WHERE 1=1

      AND CONTAINS (t.search_transactions_flag, '%'||:str||'%') > 0;

It prompts me for the bind variable 'str'. When I enter it as 'a', it returns me data, which is fine.

But when I pass it as NULL, it returns no data, whereas, here, I want it to return whole data set. Can anyone advice how to do it?

I tried rewriting query as below, but it does full table scan and does not use index. This is leading to poor performance:

SELECT *

  FROM my_transactions t

WHERE 1=1

      AND (:str IS NULL OR CONTAINS (t.search_transactions_flag, '%'||:str||'%') > 0);

Appreciate any help here!

Thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2016
Added on Aug 4 2016
8 comments
2,373 views