Oracle:外部表抛出异常

时间:2017-11-27 08:14:14

标签: plsql oracle10g

我正在尝试执行此脚本,为我在db之外的文件创建外部表。脚本如下:

DECLARE

FILENAME VARCHAR2 := 'actual_data.txt';

BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE ACTUAL_DATA_1 (
  ID      NUMBER(5),
  MSISDN    VARCHAR2(20),
  RECHARGE_DATE DATE,
  RECAHRGE_AMOUNT  NUMBER(25)
)
ORGANIZATION EXTERNAL (
  TYPE ORACLE_LOADER
  DEFAULT DIRECTORY USER_DIR
  ACCESS PARAMETERS (
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    MISSING FIELD VALUES ARE NULL
    (
  ID      NUMBER(5),
  MSISDN    VARCHAR2(20),
  RECHARGE_DATE DATE,
  RECAHRGE_AMOUNT  NUMBER(25)
    )
  )
  LOCATION (''' || FILENAME || ''')
)
PARALLEL 5
REJECT LIMIT UNLIMITED;';
END;
/

但是我收到了这个错误:

FIELDS TERMINATED BY ','

                          *
ERROR at line 17:
ORA-06550: line 17, column 27:
PLS-00103: Encountered the symbol "," when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem return
returning <an exponent (**)> <> or != or ~= >= <= <> and or
like LIKE2_ LIKE4_ LIKEC_ between into using || multiset bulk
member SUBMULTISET_

ORA-06550: line 29, column 25:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
) , * & | = - + < / > at in is mod remainder not rem => ..
<an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
LIKE4_ LIKEC_ between || member

有人可以帮助oracle新手吗?

1 个答案:

答案 0 :(得分:0)

请指定VARCHAR2防御的强制尺寸。

FILENAME VARCHAR2(n):='actual_data.txt';

n可以在1 ... 32767之间 示例:FILENAME VARCHAR2(400):='actual_data.txt';