暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle文本索引12.2

askTom 2017-04-03
526

问题描述

团队,

刚刚开始从文档中学习Oracle文本。

http://docs.oracle.com/database/122/CCAPP/getting-started-with-oracle-text.htm#CCAPP9645

drop table text_demo purge;
create table text_demo (x int,docs varchar2(100));
INSERT INTO text_demo VALUES(1, 'California is a state in the US.');
INSERT INTO text_demo VALUES(2, 'Paris is a city in France.');
INSERT INTO text_demo VALUES(3, 'France is in Europe.');
commit;

create index text_demo_idx on text_demo(docs)
 indextype is ctxsys.context 
 parameters( 'filter ctxsys.null_filter
  section group ctxsys.html_section_group' );

when tried to run the example from the above link got this error.

demo@ORA12C> declare
  2     x clob;
  3     y varchar2(40);
  4     l_len int := 40;
  5  begin
  6     ctx_doc.markup('text_demo_idx','3','France',x);
  7     dbms_lob.read(x,l_len,1,y);
  8     dbms_output.put_line( 'y = '||y);
  9     dbms_lob.freetemporary(x);
 10  end;
 11  /
declare
*
ERROR at line 1:
ORA-20000: Oracle Text error:
DRG-11445: rowid value is invalid: 3
ORA-06512: at "CTXSYS.DRUE", line 171
ORA-06512: at "CTXSYS.CTX_DOC", line 2259
ORA-06512: at line 6


demo@ORA12C>

专家解答

主键 :-)

SQL> drop table text_demo purge;

Table dropped.

SQL> create table text_demo (x int primary key,docs varchar2(100));
                                  ^^^^^^^^^^^^^

Table created.

SQL> INSERT INTO text_demo VALUES(1, 'California is a state in the US.');

1 row created.

SQL> INSERT INTO text_demo VALUES(2, 'Paris is a city in France.');

1 row created.

SQL> INSERT INTO text_demo VALUES(3, 'France is in Europe.');

1 row created.

SQL> commit;

Commit complete.

SQL>
SQL> create index text_demo_idx on text_demo(docs)
  2   indextype is ctxsys.context
  3   parameters( 'filter ctxsys.null_filter section group ctxsys.html_section_group' );

Index created.

SQL>
SQL> declare
  2         x clob;
  3         y varchar2(80);
  4         l_len int := 40;
  5      begin
  6         ctx_doc.markup('text_demo_idx','3','France',x);
  7         dbms_lob.read(x,l_len,1,y);
  8         dbms_output.put_line( 'y = '||y);
  9         dbms_lob.freetemporary(x);
 10     end;
 11     /
y = <<>> is in Europe.

PL/SQL procedure successfully completed.



「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论