Thank you in advance for reading my post and helping me..
Scenario:
I have 50 tables whose names are in a file export.sql, i use the below command to export all these tables one by one
cat export.sql|while read tn
do
echo "export to $tn.del of del select from $tn"
done
Problem:
The problem is when this job stops some where in between working on these 50 tables, for ex on 24th table. When i restart the script, i would like the script to know the last worked table name and then continue from the next table so that i dont backup the table twice.
Please help me out and let me know if any questions
The problem is, your script doesn't know the last table the database successfully imported -- it only knows what ones it printed.
If these are long operations, then I wouldn't see any harm in running these operations individually instead of piping them all into one database call. That way you could tell when the database finished, by when the DBMS quits. You'd also get its return value, which is useful to check.
How to do this depends on what your code is, as ahmed101 said.
We require information from you. We don't know what DBMS utility you're using. What, exactly, do you type to run that output file against the database?
Can't you either remove each table exported from that file or write each table exported to a log file to be eliminated from export.sql (e.g. grep -v ) for the next run?
while read tn
do
if ! db2 "export to $tn.del of del select from $tn"
then
echo "Couldn't export $tn"
echo "Couldn't export $tn" >&2
break
fi
echo "Exported $tn"
done < export.sql > logfile