Search code examples
oraclesql-loadercontrolfile

Columns with leading underscore in Oracle SQL Loader


I want to load data in an Oracle database via SQL Loader. Here is my control file. I cut out the middle part that its not too long..

OPTIONS (BINDSIZE=512000, ROWS=10000) 
LOAD DATA 
CHARACTERSET UTF8
APPEND
INTO TABLE EIDESWTDOC 
FIELDS TERMINATED BY '~' 
 OPTIONALLY ENCLOSED BY '"' 
TRAILING NULLCOLS (
MANDT CHAR(6)"NVL(:MANDT,' ')"
, SWITCHNUM CHAR(40)"NVL(:SWITCHNUM,' ')"
, POD CHAR(44)"NVL(:POD,' ')"
, SWITCHTYPE "NVL(:SWITCHTYPE, 0.0)"
, OWNER CHAR(20)"NVL(:OWNER,' ')"
, SWTVIEW "NVL(:SWTVIEW, 0.0)"
, MOVEINDATE DATE 'YYYY-MM-DD'
, MOVEOUTDATE DATE 'YYYY-MM-DD'
.....
, SP_INITIATOR CHAR(20)"NVL(:SP_INITIATOR,' ')"
, _IDEXGE_NONFIXED CHAR(2)"NVL(:_IDEXGE_NONFIXED,' ')"
, _IDEXGE_MRPERIO CHAR(4)"NVL(:_IDEXGE_MRPERIO,' ')"
)   

Because of the columns beginning with an underscore I get a syntax error (illegal combination of non-alphanumerical characters). I already tried quoting it but nothing works. Has anybody a solution for this issue?

Best regards, Chris


Solution

  • Hi Quoting seems to work.

    desc temp ;
    Name      Null? Type          
    --------- ----- ------------- 
    FIRSTNAME       VARCHAR2(255) 
    _Address        VARCHAR2(255) 
    

    Control File

    LOAD DATA
      APPEND INTO TABLE TEMP
      FIELDS TERMINATED BY ','
      (FirstName CHAR,
      "_Address" CHAR)
    

    Execution log

    $ sqlldr ***/*** control="/home/venkat/Desktop/sqlLoader/load.ctl" data = "/home/venkat/Desktop/sqlLoader/data.txt"
    
    SQL*Loader: Release 11.2.0.2.0 - Production on Wed Nov 21 00:59:36 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 2
    

    But whenever i try without quoting am getting the exact same error that your reported

    Control File

    LOAD DATA
      APPEND INTO TABLE TEMP
      FIELDS TERMINATED BY ','
      (FirstName CHAR,
      _Address CHAR)
    

    Execution log

    $ sqlldr ***/*** control="/home/venkat/Desktop/sqlLoader/load.ctl" data = "/home/venkat/Desktop/sqlLoader/data.txt"
    
    SQL*Loader: Release 11.2.0.2.0 - Production on Wed Nov 21 01:05:23 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    SQL*Loader-350: Syntax error at line 5.
    Illegal combination of non-alphanumeric characters
      _Address CHAR)
      ^
    

    PS : Try to quote all column names that are beginning with underscore.