如何允许在 'B&B' 上使用 CONTAINS 进行搜索,而不会因为 & 而得到 'Enter Substitution Variable' 的提示,并且只得到 'B&B'

How to allow search using CONTAINS on 'B&B' without getting the prompt for 'Enter Substitution Variable' because of the & and get only 'B&B'

我正在执行全局索引的 CLOB 搜索,因此我可以使用 CONTAINS 函数。我要搜索的短语是 'B&B'。我已经尝试了多种方法来转义 & 所以它不会被视为用户输入的提示。我做不到。

select * from table where contains(txt, '({B&B})')>0;--this gives me substitution variable prompt

select * from table where contains(txt, '({B}{&}{B})')>0;--this finds 'B B'

select * from table where contains(txt, '(B{&}B)')>0;--this finds 'B B'

select * from table where contains(txt, '({B&B})')>0;--this gives me substitution variable prompt

select * from table where contains(txt, '({B&}B)')>0;--this finds 'B B', 'B.B', 'B&B'

select * from table where contains(txt,'NEAR (({B&},(B)),1)') > 0;--this finds 'B B', 'B.B', 'B&B'

select * from table where txt like '%B&B%';--this gives me substitution variable prompt

我无法停用使用替换变量提示的功能,所以这必须在代码中完成。

我需要忽略所有 'B B'、'B.B' 的出现,并只return 在此字段中具有 'B&B' 的行。

我知道,这是一个 CLOB。无论如何,INSTR 会有什么好处吗?

SQL> create table test (txt clob);

Table created.

SQL> set define off
SQL> insert into test
  2    select 'This is an example which does not contain BB, B B, B.B' from dual union all
  3    select 'Query should return B&B because it is here' from dual;

2 rows created.

SQL> select txt
  2  from test
  3  where instr(txt, 'B&B') > 0;

TXT
--------------------------------------------------------------------------------
Query should return B&B because it is here

SQL>