SQL Loader Error: “Variable length field exceeds maximum length.”

后端 未结 2 1401
孤独总比滥情好
孤独总比滥情好 2021-01-02 09:00

I have a SQL Loader Control file,

LOAD DATA  
INFILE \'test.txt\'  
INTO TABLE TEST replace  
fields terminated \"|\" optionally enclosed by \'\"\' TRAILING          


        
相关标签:
2条回答
  • 2021-01-02 09:41

    +1 for DCookie, but to expand on that it's important to distinguish between data types as specified in a table and data types in a SQL*loader control file as they mean rather different things, confusingly.

    Start with a look at the the documentation, and note that when loading regular text files you need to be using the "portable" data types.

    Varchar is a "non-portable" type, in which:

    ... consists of a binary length subfield followed by a character string of the specified length

    So as DCookie says, CHAR is the thing to go for, and INTEGER EXTERNAL is a very commonly used SQL*Loader data type which you'd probably want to specify for DOCUMENTID etc.

    0 讨论(0)
  • 2021-01-02 09:46

    Don't define your data fields as VARCHAR2 and INTEGER. Use CHAR. Most of the time, when loading data from a text file, you want to use CHAR, or perhaps DATE, although even that is converted from a text form. Most of the time you don't even need a length specifier. The default length for a CHAR field is 255. Your control file should look something like:

    LOAD DATA
    INFILE "test.txt"
    INTO TABLE TEST replace
    fields terminated "|" optionally enclosed by '"' TRAILING NULLCOLS
    (
      DOCUMENTID,
      CUSTID,
      USERID ,
      FILENAME,
      LABEL,
      DESCRIPTION CHAR(2000),
      POSTDATE DATE "YYYY-MM-DD HH24:MI:SS" NULLIF POSTDATE=BLANKS,
      USERFILENAME,
      STORAGEPATH
    )
    
    0 讨论(0)
提交回复
热议问题