Hi
I have a text file , contents are
Line1:field1,field2,field3,field4,field5,field6.......field20
Line2:field1,field2,field3,field4,field5,field6.......field20
Line3:field1,field2,field3,field4,field5,field6.......field20
....and so on...
I want to read this file and insert the data into table.
How can I do that...can anybody help ?
I tried to read the text file , each line, cut the fields, make connection to database and then execute the Insert Statement....
But when I do this the Insert statement does not execute.
Can anybody guide me how do I achieve this ?
#####Connecting sqlplus to check the connectivity
sqlplus -s /nolog <<EOF>/dev/null
connect ${DB_LOGIN}/${DB_PASSWORD}@${DB_NAME}
cat /$FILEPATH/$FILENAME | while read LINE
do
echo ${LINE}
acctno=`echo $LINE | cut -f1 -d','`
echo $acctno
salutation=`echo $LINE | cut -f2 -d','`
name=`echo $LINE | cut -f3 -d','`
billdate=`echo $LINE | cut -f4 -d','`
totaldue=`echo $LINE | cut -f5 -d','`
billdeductiondate=`echo $LINE | cut -f6 -d','`
billduedate=`echo $LINE | cut -f7 -d','`
templatecode=`echo $LINE | cut -f8 -d','`
billid=`echo $LINE | cut -f9 -d','`
emailid=`echo $LINE | cut -f10 -d','`
brnno=`echo $LINE | cut -f11 -d','`
billsummaryid=`echo $LINE | cut -f12 -d','`
batchno=`echo $LINE | cut -f13 -d','`
emailfile=`echo $LINE | cut -f16 -d','`
echo "Insert into table"
spool ${SYS_TEMP_DIR}/${JOB_ID}_db_sql.log
INSERT INTO SendMailDetails (acctno) values ('${acctno}');
echo "Table Appended"
commit;
spool off;
exit;
EOF
done
I also tried:
MYCOMMAND=`awk '$1' ${FILEPATH}${FILENAME}`
sqlplus -s /nolog <<EOF>/dev/null
connect ${DB_LOGIN}/${DB_PASSWORD}@${DB_NAME}
spool my.log
Insert into SendMailDetails(acctno) values($MYCOMMAND);
spool off
commit;
exit
EOF;
But am unsuccessfull, Please help.....