Index: /trunk/DataCheck/Tools/fill_r750.sh
===================================================================
--- /trunk/DataCheck/Tools/fill_r750.sh	(revision 19495)
+++ /trunk/DataCheck/Tools/fill_r750.sh	(revision 19496)
@@ -4,6 +4,14 @@
 sqlpw=/home/$USER/.mysql.pw.op
 dbname=factdata
-# fill only corrected R750
-#short="yes" # comment line to fill also reference values
+
+query="SELECT Max(fPeriod) FROM RunInfo WHERE NOT ISNULL(fR750Cor)"
+pmaxcor=`mysql --defaults-file=$sqlpw -s -e "$query" `
+echo "fR750Cor is already filled up to P"$pmaxcor
+
+query="SELECT Max(fPeriod) FROM RunInfo WHERE NOT ISNULL(fR750Ref)"
+pmaxref=`mysql --defaults-file=$sqlpw -s -e "$query" `
+echo "fR750Ref is already filled up to P"$pmaxref
+
+
 
 # setup for zd- and th-correction: 
@@ -17,17 +25,8 @@
 query="UPDATE RunInfo SET "
 query=$query" fR750Cor=round(fNumThreshold750/("$min")/("$cor"),2) "
-query=$query" WHERE fRunTypeKey=1 AND NOT (("$min")/("$cor"))=0"
+query=$query" WHERE fRunTypeKey=1 AND NOT (("$min")/("$cor"))=0 "
+query=$query" AND fPeriod>="$pmaxcor
 echo $query
 mysql --defaults-file=$sqlpw -s -e "$query" 
-
-# todo: replace this by trigger in DB (finalize correction formula for this)
-
-if [ "$short" == "yes" ]
-then
-   echo ""
-   echo "Exit (short=yes)" 
-   exit
-fi
-
 
 # reference values for corrected R750
@@ -126,9 +125,21 @@
        240.0 #92 (current period)
        )
+if [ ${#rates[@]} -lt $pmaxref ]
+then 
+   ${#rates[@]}" "$pmaxref 
+   exit
+fi 
+
+if [ "$doupdate" == "yes" ]
+then 
+   numstart=0
+else
+   numstart=$pmaxref
+fi
 
 # fill reference values
 echo ""
 echo "Filling the reference values for the corrected R750 for "${#rates[@]}" periods to the DB..."
-for (( i=0; i < ${#rates[@]} ; i++)) 
+for (( i=$numstart; i < ${#rates[@]} ; i++)) 
 do
    echo "Filling P"$i
@@ -143,4 +154,9 @@
    mysql --defaults-file=$sqlpw -s -e "$query" 
 done
+
+if [ $numstart -gt 0 ]
+then
+   exit
+fi
 
 echo "Filling split periods..."
