#!/bin/bash b.sh
for i in $(cat ~/.supplier_details.csv ) loop
do
v_supplier=`awk -F "," '{print $1} $i`
v_supplier_name=`awk -F "," '{print $2} $i`
v_supplier_address=`awk -F "," '{print $3} $i`
checking_non_numeric=`echo $v_supplier|grep -i [A-z]|wc -l`
checking_numeric=`echo $v_supplier_name|grep [0-9]|wc -l`
if [ $checking_non_numeric -gt 0 ]
then
echo " error: Invalid data for supplier "
else
sqlplus -s user/password@database << EOF
create table t(supplier number);
insert into t(supplier)
values( $v_supplier);
exit ;
EOF ;
fi
if [ $checking_numeric -gt 0 ]
then
echo " error: Invalid data for supplier name "
else
sqlplus -s user/password@database << EOF
alter table t1 add supplier_name varchar2(50) ;
insert into t(supplier_name)
values( $v_supplier_name);
exit;
EOF;
fi
sqlplus -s user/password@database << EOF
alter table t1 add supplier_address varchar2(100);
insert into t(supplier_address)
values($supplier_address)
exit;
EOF;
done
答案 0 :(得分:0)
第6行到第8行在awk命令中有一个不成对的单引号。
应该是
v_supplier=`awk -F "," '{print $1}' $i`
v_supplier_name=`awk -F "," '{print $2}' $i`
v_supplier_address=`awk -F "," '{print $3}' $i`