将外部表创建指令转换为PLSQL过程时出错

时间:2013-02-17 16:30:06

标签: oracle plsql

我在将单个外部表指令转换为PLSQL过程时遇到了一些问题。 特别是,这是外部表创建指令,可以很好地工作。

create table TMP_TBL (
  id VARCHAR2(10)
)
organization external (
  TYPE ORACLE_LOADER
  default directory DATA_DIR
  access parameters (
    RECORDS DELIMITED BY NEWLINE
    fields terminated by '|'
    missing field values are null
  )
  location ('test.txt')
)
reject limit unlimited;

我正在尝试用这个PLSQL程序来创建给定外部数据文件的表。这就是我从现在开始做的事情,但是当我打电话时我还有一些问题。

PROCEDURE CREATE_TMP_TBL(FILENAME VARCHAR2) IS
  BEGIN
    EXECUTE IMMEDIATE 'create table TMP_TBL (
      id VARCHAR2(10)
    )
    organization external (
      type oracle_loader
      default directory DATA_DIR
      access parameters (
        records delimited by newline
        fields terminated by ''|''
        missing field values are null
      )
      location ('''||FILENAME||''')
    )
    reject limit unlimited;';
  END CREATE_TMP_TBL;

使用以下命令执行该过程:

exec pkg_load.CREATE_TMP_TBL('test.txt');

它给了我这个错误:

Error report:
ORA-00911: invalid character
ORA-06512: at "PKG_LOAD", line 43
ORA-06512: at line 1
00911. 00000 -  "invalid character"
*Cause:    identifiers may not start with any ASCII character other than
           letters and numbers.  $#_ are also allowed after the first
           character.  Identifiers enclosed by doublequotes may contain
           any character other than a doublequote.  Alternative quotes
           (q'#...#') cannot use spaces, tabs, or carriage returns as
           delimiters.  For all other contexts, consult the SQL Language
           Reference Manual.
*Action:

第43行是CREATE_TMP_TBL过程的“BEGIN”数字行。

的信息:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE   11.2.0.2.0  Production"
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

欢迎任何解决此问题的建议。 在建议中感谢,

卡罗

1 个答案:

答案 0 :(得分:1)

从语句末尾删除分号:

reject limit unlimited;'; 

即改为

reject limit unlimited';