我想将 .csv 文件导入到下面的 Oracle 数据库表中,但它不起作用,并且日志文件为空,没有输出。
我的 shell 脚本如下:
并且日志文件始终为空
下面是 .csv 文件的示例
SendingFri,LoggingTime,RenewalNumber,TransactionType,Status,Duration
22997186945,2023-07-25-00:05:56.301,23900032093333,Payment,SUCCESS,null
22951547347,2023-07-25-00:04:12.794,23900336289912,Payment,SUCCESS,null
#!/bin/bash
# Oracle Database Connection Details
USERNAME='abc'
PASSWORD="abc"
HOST="myip"
PORT="1521"
SERVICE_NAME="abc"
# CSV File Details
CSV_FILE="/home/hdegboevi/modified5.csv"
TABLE_NAME="myCANALINFORMATION"
# Control File
CONTROL_FILE="my_control_file.ctl"
# Create a control file
cat <<EOF > $CONTROL_FILE
LOAD DATA
INFILE '$CSV_FILE'
APPEND INTO TABLE $TABLE_NAME
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
SENDINGFRI,
LOGGINGTIME,
RENEWALNUMBER,
TRANSACTIONTYPE,
STATUS,
DURATON
)
EOF
# Run SQL*Loader
sqlldr $USERNAME/$PASSWORD@$HOST:$PORT/$SERVICE_NAME control=$CONTROL_FILE log=/home/hdegboevi/sqlldr.log /home/hdegboevi
# Check the log for errors
if grep "ORA-" sqlldr.log; then
echo "Error occurred during data load. Please check sqlldr.log for details."
else
echo "Data loaded successfully."
fi