Quote:
Originally Posted by
Devesh5683
Hi,
I m trying to connect oracle database from inside while loop.
I m trying to put the output of sql query in a flat file.
Anyone please help me out.
cat $FILE_NAME | \
while read da_name
do
$ORACLE_HOME/bin/sqlplus -s user_name/password@instance << EOF >> $OUTPUT_FILE
select global_name from global_name;
EOF
done
Getting output as output.
thanks in advance
###############################
while read da_name
do
RETVAL=`sqlplus -l user_name/password@instance <<EOF
insert into ODS_T_CFS_DUMP(FILE_NAME, REGION_ID, SDP_ID, SEQUENCE_ID, TOTAL_RECORDS) values ('$file','$region_id','$sdp_id','$sequence_id', '$sub_records');
EXIT
EOF`
done
Here you can get the SQL-Query output in the RETVAL Variable.
You can use this $RETVAL valve anywhere in the script.
#####################################