Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle SQLLDR格式的单位数月份和日期_Oracle_Sql Loader - Fatal编程技术网

Oracle SQLLDR格式的单位数月份和日期

Oracle SQLLDR格式的单位数月份和日期,oracle,sql-loader,Oracle,Sql Loader,在我的sqlldr ctl文件中,我有以下条目 REPORT_MONTH "decode(trim(:REPORT_MONTH),null,null,to_date(trim(:REPORT_MONTH), 'MMYYYY'))" 但如果数据为2018年2月22日的22018次通过,则此操作将失败。我知道java支持“MYYYY”,但我搜索后发现SQL没有这种格式。那么如何用一位数解析日期呢 此外,我还有一个字段,其中应允许使用个位数的月份和日期,如“2018年9月9日” DISP_DATE

在我的sqlldr ctl文件中,我有以下条目

REPORT_MONTH "decode(trim(:REPORT_MONTH),null,null,to_date(trim(:REPORT_MONTH), 'MMYYYY'))"
但如果数据为2018年2月22日的22018次通过,则此操作将失败。我知道java支持“MYYYY”,但我搜索后发现SQL没有这种格式。那么如何用一位数解析日期呢

此外,我还有一个字段,其中应允许使用个位数的月份和日期,如“2018年9月9日”

DISP_DATE "decode(trim(:DISP_DATE),null,null,to_date(trim(:DISP_DATE), 'MM/DD/YYYY'))"

在第一种情况下,您需要将日期填充到六个字符,并在左侧用零填充。在第二种情况下,使用格式字符串
'MM/DD/YYYY'
就可以了。以下示例显示了如何完成此操作:

SELECT TO_DATE(LPAD('22018', 6, '0'), 'MMYYYY') AS SIX_DIGIT_DATE,
       TO_DATE('9/9/2018', 'MM/DD/YYYY') AS EIGHT_DIGIT_DATE
  FROM DUAL;
祝你好运