0
votes

I want to test Oracle's CTX_DOC.TOKENS procedure in order to count the number of occurrence of a string into a document. For this, I have:

create table documents (id number primary key, text bfile);

insert into documents values (1, bfilename('MY_DIR','12things_about_122.pdf'));

create index documents_idx on documents (text) indextype is ctxsys.context;

declare
    the_tokens ctx_doc.token_tab;
begin
    ctx_doc.set_key_type ('PRIMARY_KEY');
    ctx_doc.tokens('documents_idx','1',the_tokens);
    dbms_output.put_line('Number of tokens: '|| the_tokens.count);
 end;

When I test this, the PLSQL part fails with:

Error report:

ORA-20000: Oracle Text error:

DRG-10001: can not access result table the_tokens

ORA-06512: at "CTXSYS.DRUE", line 160

ORA-06512: at "CTXSYS.CTX_DOC", line 862 ORA-06512: at line 5

  1. 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.

Can you help me to understand what is needed much more in order to work correctly, please?

Thank you,

1
does the procedure, work if you just upload text(.txt) files ? It works for me for both PDF and Text. Can you check if you have given correct access to the table and are running from correct schema. According to oracle the error message means - Specified table does not exist or server does not have write privilegesSudipta Mondal
The code is not working either for PDF or TXT files. For the access, I provided ALL rights: GRANT ALL on ctxsys.doc to my_user The PLSQL code was executed from my_user schema. As far as I can see, all requirements seems to be fulfilled. With what user have you executed the code, please?mikcutu
it seems that the problem is coming from the ctx_doc.tokens('documents_idx', '1', 'the_tokens'); because if I comment it, no error occurs.mikcutu
did you try having look at the code of ctx_doc package ?Sudipta Mondal
yes, I did, but it is wrapped.mikcutu

1 Answers

0
votes

it seems that the answer was too easy to be seen from the 1st time:

It was necessary to referenciate the ctx_doc.token_tab; with schema name, too.

Instead of the_tokens ctx_doc.token_tab, I had to do the_tokens ctxsys.ctx_doc.token_tab;