在存储过程plsql中创建目录

时间:2014-11-12 13:34:01

标签: stored-procedures dynamic plsql directory

我有这段代码:

create or replace PROCEDURE insert_dir(id number, filename varchar2, dir varchar2)
IS  
  sqlQ varchar2;
BEGIN   
   sqlQ := 'create directory DIR0001 as '||dir;
    EXECUTE IMMEDIATE (sqlQ);
END;

我正在尝试在存储过程中创建一个目录并通过参数传递值,但我收到错误:

   Package or function INSERT_DIR is in an invalid state
06575. 00000 -  "Package or function %s is in an invalid state"
*Cause:    A SQL statement references a PL/SQL function that is in an
           invalid state. Oracle attempted to compile the function, but
           detected errors.
*Action:   Check the SQL statement and the PL/SQL function for syntax
           errors or incorrectly assigned, or missing, privileges for a
           referenced object.

通话程序:

CALL insert_dir(3,'pic.jpg','C:\Users\User\Desktop\media');

有人知道我做错了什么吗?

1 个答案:

答案 0 :(得分:1)

编译过程后,应该说“使用编译错误创建过程。”

如果您发出SHOW ERRORS,它会告诉您编译错误以及哪一行。

在这种情况下,错误在这一行 - 声明需要VARCHAR2的大小,例如:

sqlQ varchar2(4000);