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'

我不知道问题可能是什么。

4

1 回答 1

0

您需要添加单引号,例如:

command := 'CREATE OR REPLACE DIRECTORY DWH_DIR AS ''' || dir_path || '''';
于 2013-08-22T02:05:57.730 回答