如何在使用sql loader时将时区与时区转换为仅时间戳

时间:2014-03-17 06:49:15

标签: types timestamp sql-loader

enter code here

       load data
         infile '/u01/app/oracle/scripts/Elite_export.csv'
         discardfile '/u01/app/oracle/scripts/data.dis'
         into table TBLRADIUSCUSTOMER_TEST
         fields terminated by ","
        ( 
USERNAME ,
PASSWORD ,
CUSTOMERSTATUS ,
CONCURRENTLOGINPOLICY ,
RADIUSPOLICY ,
ADDITIONALPOLICY ,
PARAM1 ,
PARAM2 ,
PARAM3 ,
PARAM4 ,
CUSTOMERTYPE ,
CALLINGSTATIONID ,
CUI ,
MACVALIDATION ,
IMSI ,
MEID ,
MSISDN ,
MDN ,
GEOLOCATION ,
CREATEDATE  "TO_TIMESTAMP(:CREATEDATE,'DD-MM-YY HH24:MI:SS.ff')",
LASTMODIFIEDDATE "TO_TIMESTAMP(:LASTMODIFIEDDATE,'DD-MM-YY HH24:MI:SS.ff')"
  )

我面临的错误如下:

enter code here

     SQL*Loader: Release 11.2.0.3.0 - Production on Mon Mar 17 12:08:44 2014

      Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

       Control File:   data.ctl
       Data File:      /u01/app/oracle/scripts/Elite_export.csv
      Bad File:     Elite_export.bad
      Discard File: /u01/app/oracle/scripts/data.dis 
      (Allow all discards)

      Number to load: ALL
      Number to skip: 0
      Errors allowed: 50
      Bind array:     64 rows, maximum of 256000 bytes
      Continuation:    none specified
      Path used:      Conventional

      Table TBLRADIUSCUSTOMER_TEST, loaded from every logical record.
      Insert option in effect for this table: INSERT

      Column Name                  Position   Len  Term Encl Datatype
       ------------------------------ ---------- ----- ---- ---- ---------------------
      USERNAME                            FIRST     *   ,       CHARACTER            
      PASSWORD                             NEXT     *   ,       CHARACTER            
      CUSTOMERSTATUS                       NEXT     *   ,       CHARACTER            
      CONCURRENTLOGINPOLICY                NEXT     *   ,       CHARACTER            
      RADIUSPOLICY                         NEXT     *   ,       CHARACTER            
      ADDITIONALPOLICY                     NEXT     *   ,       CHARACTER            
      PARAM1                               NEXT     *   ,       CHARACTER            
      PARAM2                               NEXT     *   ,       CHARACTER            
      PARAM3                               NEXT     *   ,       CHARACTER            
      PARAM4                               NEXT     *   ,       CHARACTER            
      CUSTOMERTYPE                         NEXT     *   ,       CHARACTER            
      CALLINGSTATIONID                     NEXT     *   ,       CHARACTER            
      CUI                                  NEXT     *   ,       CHARACTER            
      MACVALIDATION                        NEXT     *   ,       CHARACTER            
      IMSI                                 NEXT     *   ,       CHARACTER            
      MEID                                 NEXT     *   ,       CHARACTER            
      MSISDN                               NEXT     *   ,       CHARACTER            
      MDN                                  NEXT     *   ,       CHARACTER            
     GEOLOCATION                          NEXT     *   ,       CHARACTER            
     CREATEDATE                           NEXT     *   ,       CHARACTER            
           SQL string for column : "TO_TIMESTAMP(:CREATEDATE,'DD-MM-YY HH24:MI:SS.ff')"
     LASTMODIFIEDDATE                     NEXT     *   ,       CHARACTER            
      SQL string for column : "TO_TIMESTAMP(:LASTMODIFIEDDATE,'DD-MM-YY HH24:MI:SS.ff')"

     value used for ROWS parameter changed from 64 to 47
     Record 1: Rejected - Error on table TBLRADIUSCUSTOMER_TEST, column CREATEDATE.
     ORA-01830: date format picture ends before converting entire input string

     Record 2: Rejected - Error on table TBLRADIUSCUSTOMER_TEST, column CREATEDATE.
      ORA-01830: date format picture ends before converting entire input string


     and so on.....

使用SQL Loader将TIMESTAMP中的数据类型更改为TIMESTAMP(6)时需要帮助

请建议我在将数据加载到Oracle表时如何丢弃时区详细信息

1 个答案:

答案 0 :(得分:0)

如果您不关心时间戳,只想要日期中的数字,丢弃时区信息,请使用substr丢弃时区信息:

CREATEDATE  "TO_TIMESTAMP(SUBSTR(instr(:CREATEDATE, ' ', 10),1,24),'DD-MM-YY HH24:MI:SS.ff')",

Substr以日期格式获取格式' DD-MM-YY HH24:MI:SS.ff'

instr(:CREATEDATE, ' ', 17) 

分隔符在日期和时区信息之间的位置。我假设在数字和tz信息之间会有一个空格,所以我使用17作为instr的起始位置,在“DD-MM-YY HH24:MI:SS'”之后找到第一个空格。日期部分。