![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| (sed) parsing insert statement column that crosses multiple lines | jjordan | Shell Programming and Scripting | 3 | 10-09-2007 12:23 AM |
| Need to execute the same statement | Legend986 | Shell Programming and Scripting | 8 | 10-01-2007 04:59 PM |
| How do i execute in IF ELSE Statement | laknar | Shell Programming and Scripting | 1 | 06-08-2007 02:54 AM |
| Insert TAB in echo statement | sunils27 | Shell Programming and Scripting | 5 | 08-26-2005 03:36 AM |
| awk command for INSERT statement | nattynatty | Shell Programming and Scripting | 4 | 05-10-2002 02:11 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Script does not execute Insert Statement
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 ? Code:
#####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
Code:
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;
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|