2013-08-21 63 views
0

我想使用觸發器調用的過程來創建/修改oracle目錄。我想從一個表中的值中獲取路徑,並且在該值發生變化時從觸發器中調用該過程。我在過程中下面的代碼:從表值創建目錄時出錯

CREATE OR REPLACE 
PROCEDURE update_directory(
    v_directory IN fe_system_parameter.value%type) 
AS 
    dir_path    VARCHAR2(32767); 
    command VARCHAR2(32767); 
BEGIN 
    SELECT VALUE 
    INTO dir_path 
    FROM fe_system_parameter 
    WHERE name = 'DWH_DIRECTORY'; 

    command := 'CREATE OR REPLACE DIRECTORY DWH_DIR AS ' || dir_path; 

    execute immediate(command); 
END update_directory; 

當DIR有一個包含「/」字符,例如一個值:/ DIR /,我得到以下錯誤:

PLS-00103: Encountered the symbol "/" when expecting one of the following: 

    () - + case mod new not null <an identifier> 
    <a double-quoted delimited-identifier> <a bind variable> 
    table continue avg count current exists max min prior sql 
    stddev sum variance execute multiset the both leading 
    trailing forall merge year month day hour minute second 
    timezone_hour timezone_minute timezone_region timezone_abbr 
    time timestamp interval date 
    <a string literal with character set specification> 
ORA-06512: at "SYS.DBMS_JOB", line 82 
ORA-06512: at "SYS.DBMS_JOB", line 140 
ORA-06512: at "SOMESCHEMA.TRI_UPDATE_DIRECTORY", line 3 
ORA-04088: error during execution of trigger 'SOMESCHEMA.TRI_UPDATE_DIRECTORY' 

我不不知道問題可能是什麼。

回答

0

您需要添加單引號,例如:

command := 'CREATE OR REPLACE DIRECTORY DWH_DIR AS ''' || dir_path || ''''; 
+0

謝謝,這正是問題。 –