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;
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
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
f_get_tables()
{
rm -f ${lv_temp1}
sqlplus ${userid} </dev/null
set colsep ${lv_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;
spool off;
exit
!
if [ "$?" -ne 0 ] ; then
echo "sqlplus $userid error in get table name <"$?">!!"
echo "please check userid and passwd or database."
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}
for table in ${lv_tables}
do
rm -f lv_$table.txt
sqlplus ${userid} </dev/null
set colsep ${lv_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_$table.txt;
select * from $table;
spool off;
!
if [ "$?" -ne 0 ]
then
echo "error:sqlplus $userid error in unload table $table!!"
echo "please check userid and passwd or database."
exit
fi
if [ -f lv_$table.txt ]
then
cat lv_$table.txt | grep -v "^SQL>"|sed -e "s/ *$//g"|sed "s/$/\|/g"|sed -e "s/ *\|/\|/g" >${table}.unl
if [[ `grep "ORA-" $table.unl` = "" ]]; then
echo "unload table ${table}....\t\t\t\t\t ok"
else
cat ${table}.unl
err="$err ${table}"
fi
else
echo $0 error
fi
rm -f lv_$table.txt
done
#########################################束操作
if [[ "X$err" = "X" ]];then
echo "Unload Complete!,Thank you!"
else
echo "Unload Table $err error, please check it!"
fi
sqlplus ${userid} </dev/null
spool ${lv_temp};
desc ${table}
spool off;
exit
!
if [ "$?" -ne 0 ]
then
echo "Error:sqlplus ${userid} error in generate control file for table ${table} !"
echo "please check userid and passwd or oracle_sid."
exit
fi