2017-03-07 52 views
0

當我有這將值插入表中一個簡單的程序全文數據庫應用程序:錯誤同步上下文索引

create or replace PROCEDURE put_file 
(
    p_file_name   IN my_doc.file_name%TYPE, 
    p_upload_date  IN my_doc.upload_date%TYPE, 
    p_filesize   IN my_doc.filesize%TYPE, 
    p_filetype   IN my_doc.filetype%TYPE, 
    p_creation_date  IN my_doc.creation_date%TYPE, 
    p_modification_date IN my_doc.modification_date%TYPE, 
    p_accessed_date  IN my_doc.accessed_date%TYPE 
) AS 
dummy pls_integer; 
BEGIN 

    select count(*) into dummy from my_doc where file_name = p_file_name; 

    if dummy = 0 
     then 
     INSERT INTO my_doc (id, file_name, upload_date, filesize, filetype, content, creation_date, modification_date, accessed_date) 
     VALUES (my_doc_seq.NEXTVAL, p_file_name, p_upload_date, p_filesize, p_filetype, BFILENAME('DOCUMENTS',p_file_name), p_creation_date, p_modification_date, p_accessed_date); 

    end if; 
    ctx_ddl.sync_index; -- the error occurs here 
    COMMIT; 

END; 

爲了成功執行這個程序,我提供了所有必要的權利,以當前用戶:

grant resource, connect, ctxapp to my_user; 
/
grant execute on ctxsys.ctx_adm to my_user; 
grant execute on ctxsys.ctx_cls to my_user; 
grant execute on ctxsys.ctx_ddl to my_user; 
grant execute on ctxsys.ctx_doc to my_user; 
grant execute on ctxsys.ctx_output to my_user; 
grant execute on ctxsys.ctx_query to my_user; 
grant execute on ctxsys.ctx_report to my_user; 
grant execute on ctxsys.ctx_thes to my_user; 
grant execute on ctxsys.ctx_ulexer to my_user; 

...但是,不幸的是,當我執行我收到以下錯誤的程序:

Error starting at line 1 in command:
EXECUTE put_file('text.txt', sysdate, 12, '.txt', sysdate, sysdate, sysdate);
Error report:

ORA-20000: Oracle Text error: DRG-10017: you must be CTXSYS to do this: SYNC
ORA-06512: at "CTXSYS.DRUE", line 160
ORA-06512: at "CTXSYS.CTX_DDL", line 847
ORA-06512: at "my_user.PUT_FILE", line 24
ORA-06512: at line 1

  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.

你能告訴我我做錯了什麼嗎?

謝謝

回答

1

我想我會告訴你調用ctx_ddl.sync_index問題。你沒有傳遞任何參數。這是允許的,但the documentation tells us

"When idx_name is null, all CONTEXT, CTXRULE, and CTXXPATH indexes that have pending changes are synchronized. You must be connected as ctxsys to perform this operation. "

因此,解決方案是你需要在你的電話中包括索引的名稱。