如何使用单个控制文件将通用平面文件数据加载到两个不同的 table?

How to load common flat file data to two different table using single control file?

我无法使用单个控制文件和 .csv 数据文件将数据加载到不同的 table。 只有一个 table 数据完美加载,但第二个 table 没有加载除 .ctl 文件中定义的常量值之外的任何值

请找出我使用的代码:

OPTIONS ( ERRORS=1000000, DIRECT=FALSE, SKIP=1)
load data 
INFILE *
append into table TB1
fields terminated by "," 
optionally enclosed by '"'
trailing nullcols
(
WORK_ORDER_ID                   "TRIM(:WORK_ORDER_ID)",
REQUEST_DATE                    FILLER,
REQUEST_TYPE                    FILLER,
INSTALLATION_TYPE               "TRIM(:INSTALLATION_TYPE)",
REQUEST_STATUS                  FILLER,
WORK_STEP                       FILLER,
PROPERTY_NAME                   FILLER,
ADDRESS                         "TRIM(:ADDRESS)",
PROPERTY_CITY                   FILLER,
PROPERTY_STATE                  FILLER,
PROPERTY_ZIP                    FILLER,
DL_MARKET                       FILLER,
DL_DISPATCH_ZONE                FILLER,
PROPERTY_PHONE_NO               FILLER,
REQUEST_DESCP_NOTES             FILLER,
SITE_ESCORTS                    FILLER,
TOTAL_ROOMS                     "TRIM(:TOTAL_ROOMS)",
LOCATION_BEACONS                FILLER,
ACCESS_POINTS                   FILLER,
CREATED_BY                      CONSTANT "lv_user_id", 
LAST_UPDATED_BY                 CONSTANT "lv_user_id", 
LAST_UPDATE_DATE                SYSDATE,  
LAST_UPDATE_LOGIN               CONSTANT "lv_user_id",    
CREATION_DATE                   SYSDATE 
)

into table TB2
fields terminated by "," 
optionally enclosed by '"'
trailing nullcols
(
REQUEST_ID                      "TRIM(:REQUEST_ID)",
REQUEST_DATE                    "TRUNC(TO_DATE(TRIM(:REQUEST_DATE),'MM/DD/YYYY HH24:MI:SS'))",
REQUEST_TYPE                    "TRIM(:REQUEST_TYPE)",
INSTALLATION_TYPE               "TRIM(:INSTALLATION_TYPE)",
REQUEST_STATUS                  "TRIM(:REQUEST_STATUS)",
WORK_STEP                       "TRIM(:WORK_STEP)",
ON_PROPERTY_CONTACT             "TRIM(:ON_PROPERTY_CONTACT)",
ON_PROPERTY_EMAIL               "TRIM(:ON_PROPERTY_EMAIL)",
ON_PROPERTY_POC_MOBILE          "TRIM(:ON_PROPERTY_POC_MOBILE)",
PROPERTY_ADDRESS                "TRIM(:PROPERTY_ADDRESS)",
CREATED_BY                      CONSTANT "lv_user_id", 
LAST_UPDATED_BY                 CONSTANT "lv_user_id", 
LAST_UPDATE_DATE                SYSDATE,  
LAST_UPDATE_LOGIN               CONSTANT "lv_user_id",    
CREATION_DATE                   SYSDATE, 
STG_SEQ_ID                      "XXMTZ_AT_OP_MAS_STG_SEQ.NEXTVAL"
)

TB1 数据加载完美,但 TB2 不会将任何数据加载到 table 除了常量值

文档中描述了这种行为;它说 - 当 SQL*Loader 到达第二个 INSERT INTO 时,它会从加载第一个 INSERT INTO 期间离开的地方扫描输入数据。

换句话说,它扫描(因为它在append into table TB1期间到达逻辑记录的末尾)所以第二个table中的所有值是 NULL.

您必须通过指定位置将其"reset"到记录的开头,例如

into table TB2
...
(
REQUEST_ID   position(1)      "TRIM(:REQUEST_ID)",
...