使用 SQLLoader 将数据字段的 $ char 替换为零
Replace $ char with zero for data field using SQLLoader
文本文件包含如下数据。
041522$$$$$$$$$NAPTTALIE REVERE @1621500025 OLD ST FUNNRHILL MA1530 273 000000$$$$$$@$$$@@@@@@@@@@@@@@$$$$$$$$$$$$$$$$$$Z$$$$$$$$$$$$$$$$$$$$$$@@@$$$$$$$$$$$$$$$$$$$$$@@@@@$$$$$$$$$$$$$$$@$$$$[=10=]$$$$$$$$$$[=10=]0000$$$$$$$$$$$$@$$@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@$$$$$$$$$$$[=10=]0000$$$$$$$$$$$$$A@@@Y$$$$$$$$$$$$@@$$$$$$$$$$$$$$$$$$$@@02$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$$$@@Y@@@@@@@$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
控制文件:
LOAD DATA
CHARACTERSET "UTF8"
INFILE 'C:\bendex\MA_File38\fileout.txt'
BADFILE 'C:\bendex\MA_File38\baddata.bad'
DISCARDFILE 'C:\bendex\MA_File38\discdata.dsc'
APPEND
INTO TABLE "TMP_DATA_1220"
TRAILING NULLCOLS
(
SOURCE CONSTANT "TEST",
FILE_DTE "TRUNC(SYSDATE)",
AU_REGION POSITION (1:2),
AU_OFFICE POSITION (3:5),
AU_PGM_CATEGORY POSITION (6) ,
GRANTEE_SSN POSITION (7:15),
GRANTEE_NAME POSITION (16:38),
CAT_ELIG_IND POSITION (39),
PHONE POSITION (40:47),
ADDRESS POSITION (48:70),
CITY POSITION (71:83),
STATE POSITION (84:85),
ZIP POSITION (86:90),
CAN_NUM POSITION (91:95),
NET_INC POSITION (96:101) "TO_NUMBER(:NET_INC)",
START_DTE POSITION (102:107) "CASE WHEN :START_DTE ='$$$$$$' THEN TO_CHAR(REPLACE(:START_DTE, '$', '0')) ELSE DATE 'rrmmdd'",
LAST_UPDT_UID_NAM CONSTANT "LOADF38",
LAST_UPDT_TS "SYSTIMESTAMP"
)
**Error:**
Record 1: Rejected - Error on table "TMP_DATA_1220", column START_DTE.
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
我必须从文本文件中读取数据并加载到 table。我试图用“0”替换“$”并转换为日期字段,位置 102 到 107,但出现错误。我尝试使用 REPLACE,DECODE 不起作用。
非常感谢任何帮助。谢谢。
注意:文本文件包含全长数据,但使用 SQL 加载程序仅读取前几个数据点。
我相信如果您的开始日期无效,您会希望将其设为 NULL,不是吗?
"CASE WHEN :START_DTE ='$$$$$$' THEN NULL ELSE to_date(:START_DTE, 'rrmmdd') END"
文本文件包含如下数据。
041522$$$$$$$$$NAPTTALIE REVERE @1621500025 OLD ST FUNNRHILL MA1530 273 000000$$$$$$@$$$@@@@@@@@@@@@@@$$$$$$$$$$$$$$$$$$Z$$$$$$$$$$$$$$$$$$$$$$@@@$$$$$$$$$$$$$$$$$$$$$@@@@@$$$$$$$$$$$$$$$@$$$$[=10=]$$$$$$$$$$[=10=]0000$$$$$$$$$$$$@$$@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@$$$$$$$$$$$[=10=]0000$$$$$$$$$$$$$A@@@Y$$$$$$$$$$$$@@$$$$$$$$$$$$$$$$$$$@@02$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$$$@@Y@@@@@@@$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
控制文件:
LOAD DATA CHARACTERSET "UTF8" INFILE 'C:\bendex\MA_File38\fileout.txt' BADFILE 'C:\bendex\MA_File38\baddata.bad' DISCARDFILE 'C:\bendex\MA_File38\discdata.dsc' APPEND INTO TABLE "TMP_DATA_1220" TRAILING NULLCOLS ( SOURCE CONSTANT "TEST", FILE_DTE "TRUNC(SYSDATE)", AU_REGION POSITION (1:2), AU_OFFICE POSITION (3:5), AU_PGM_CATEGORY POSITION (6) , GRANTEE_SSN POSITION (7:15), GRANTEE_NAME POSITION (16:38), CAT_ELIG_IND POSITION (39), PHONE POSITION (40:47), ADDRESS POSITION (48:70), CITY POSITION (71:83), STATE POSITION (84:85), ZIP POSITION (86:90), CAN_NUM POSITION (91:95), NET_INC POSITION (96:101) "TO_NUMBER(:NET_INC)", START_DTE POSITION (102:107) "CASE WHEN :START_DTE ='$$$$$$' THEN TO_CHAR(REPLACE(:START_DTE, '$', '0')) ELSE DATE 'rrmmdd'", LAST_UPDT_UID_NAM CONSTANT "LOADF38", LAST_UPDT_TS "SYSTIMESTAMP" )
**Error:** Record 1: Rejected - Error on table "TMP_DATA_1220", column START_DTE. ORA-01841: (full) year must be between -4713 and +9999, and not be 0
我必须从文本文件中读取数据并加载到 table。我试图用“0”替换“$”并转换为日期字段,位置 102 到 107,但出现错误。我尝试使用 REPLACE,DECODE 不起作用。
非常感谢任何帮助。谢谢。
注意:文本文件包含全长数据,但使用 SQL 加载程序仅读取前几个数据点。
我相信如果您的开始日期无效,您会希望将其设为 NULL,不是吗?
"CASE WHEN :START_DTE ='$$$$$$' THEN NULL ELSE to_date(:START_DTE, 'rrmmdd') END"