#!/usr/bin/ksh
################################################################
# 描述: 根据一个数据库或表名来装载对应的数据文件
################################################################
lv_temp1="wk.test1"
f_get_tables()
{
rm -f ${lv_temp1}
sqlplus ${userid} </dev/null
set colsep $sep;
set echo off;
set feedback off;
set heading off;
set pagesize 0;
set linesize 1000;
set numwidth 12;
set termout off;
set trimout on;
set trimspool on;
spool ${lv_temp1};
select table_name from user_tables where table_name like 'T\\_%' escape '\';
spool off;
exit
!
if [ "$?" -ne 0 ]
then
echo "Error:sqlplus ${userid} error in load for ${userid} !"
echo "please check userid and passwd or oracle_sid."
exit
fi
if [ -f ${lv_temp1} ]
then
lv_tables=`cat ${lv_temp1} |grep -v "^SQL>" | tr -d ' '`
else
echo "Error:${lv_temp1} file not found!"
exit
fi
rm -f ${lv_temp1}
}
################################################################
lv_no=$#
case ${lv_no} in
0 )
f_get_tables;
;;
1 )
lv_tables=$1
;;
* )
echo "Usage: $0 "
exit
;;
esac
for lv_table in ${lv_tables}
do
if [ ! -f ${lv_table}.unl ]
then
echo "Error:${lv_table}.unl file not found!"
else
generate_control_file.sh ${userid} ${lv_table}
generate_execute_shell.sh ${userid} ${lv_table}
sh load_${lv_table}.sh
rm -f ${lv_table}.ctl
rm -f load_${lv_table}.sh
fi
done
阅读(623) | 评论(0) | 转发(0) |