我有一个通过 sql 查询动态创建 CTL 文件的过程。而且我必须将文件名插入到 oracle 表中。我能够让文件名显示在查询中,但它一直拒绝它。ctls 只接受数字吗?因为如果我将其硬编码为一个数字,它将起作用。如果我将其硬编码为 varchar,它将拒绝它。如何在加载时获取要插入的文件名?
' LEAD_TIME,' || chr (10) ||
' DELIVERY_TIME,' || chr (10) ||
' DELIVERY_NO,' || chr (10) ||
' FREQUENCY,' || chr (10) ||
' FREQUENCY_UNIT,' || chr (10) ||
' MODE_TYPE,' || chr (10) ||
' AUDIT_LOG_ID "' || MAX(audit_log_id) || '",' || chr (10) ||
' STAGING_STATUS_ID "1",' || chr (10) ||
' FILENAME "&fname",' || chr (10) ||
' LINENO SEQUENCE(1)' || chr (10) ||
' )' || chr (10)
from audit_log
where filename_orig = '&fname';
spool off
这是运行 sqlldr 的输出。它正确显示了文件名,但仍然拒绝该条目。
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
VENDOR FIRST * , CHARACTER
COMM_CONTRACT NEXT * , CHARACTER
SERV_CONTRACT NEXT * , CHARACTER
ADDR_CHAIN NEXT * , CHARACTER
STORE NEXT * , CHARACTER
SITE_GROUP NEXT * , CHARACTER
START_DATE NEXT * , CHARACTER
END_DATE NEXT * , CHARACTER
ORDER_DAY NEXT * , CHARACTER
ORDER_TIME NEXT * , CHARACTER
LEAD_TIME NEXT * , CHARACTER
DELIVERY_TIME NEXT * , CHARACTER
DELIVERY_NO NEXT * , CHARACTER
FREQUENCY NEXT * , CHARACTER
FREQUENCY_UNIT NEXT * , CHARACTER
MODE_TYPE NEXT * , CHARACTER
AUDIT_LOG_ID NEXT * , CHARACTER
SQL string for column : "26004459"
STAGING_STATUS_ID NEXT * , CHARACTER
SQL string for column : "1"
FILENAME NEXT * , CHARACTER
SQL string for column : "filenamexxx.csv"
LINENO SEQUENCE (1, 1)
value used for ROWS parameter changed from 64 to 51
Table DISA_STAGING_SUPP_SCHEDULE:
0 Rows successfully loaded.
6 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.