Index: /trunk/ippToPsps/perl/ippToPsps/Gpc1Db.pm
===================================================================
--- /trunk/ippToPsps/perl/ippToPsps/Gpc1Db.pm	(revision 29192)
+++ /trunk/ippToPsps/perl/ippToPsps/Gpc1Db.pm	(revision 29193)
@@ -90,5 +90,7 @@
 ###########################################################################
 sub getExposureListFromDvoDb {
-    my ($self, $dvoDb, $exposures) = @_;
+    my ($self, $dvoDb, $exposures, $lastExposure) = @_;
+
+    if (!defined $lastExposure) {$lastExposure = 0;}
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -100,14 +102,8 @@
         WHERE addRun.dvodb LIKE '$dvoDb' 
         AND addRun.state = 'full'
+        AND rawExp.exp_id > $lastExposure
         ORDER BY exp_id ASC;
 SQL
 
-    #AND rawExp.exp_id > 133887
-    #AND filter = 'r.00000'
-    #AND rawExp.dateobs <= '2010-03-12'
-    #AND rawExp.exp_id > $lastExpId
-    #AND camRun.label LIKE '%$label%'
-    #AND rawExp.exp_id > 136561
-    #AND camRun.dist_group LIKE 'sas'
     #AND rawExp.decl >= '-0.157079633' AND rawExp.decl <= '0.157079633' Jims Dec range
 
@@ -115,12 +111,11 @@
     ${$exposures} = $query->fetchall_arrayref();
     my $numOfExposures = scalar @{${$exposures}};
-    if ($numOfExposures > 0) {
-    
-        print "* Found $numOfExposures exposures in DVO Db '$dvoDb'\n";
-        return 1;
-    }
 
-    print "* No exposures found in DVO Db '$dvoDb'\n";
-    return 0;
+    # message
+    if ($numOfExposures) {print "* Found $numOfExposures exposures";}
+    else { print "* No exposures found"; }
+    print " in DVO Db '$dvoDb' (counting from exposure $lastExposure)\n";
+
+    return ($numOfExposures) ? 1 : 0;
 }
 
Index: /trunk/ippToPsps/perl/makeDetections.pl
===================================================================
--- /trunk/ippToPsps/perl/makeDetections.pl	(revision 29192)
+++ /trunk/ippToPsps/perl/makeDetections.pl	(revision 29193)
@@ -21,4 +21,5 @@
 my $output = undef;
 my $singleExpId = undef;
+my $lastExpId = undef;
 my $datastoreProduct = undef;
 my $force = undef;
@@ -33,4 +34,5 @@
         'dvolocation|l=s' => \$dvoPath,
         'expid|e=s' => \$singleExpId,
+        'lastexpid|x=s' => \$lastExpId,
         'product|p=s' => \$datastoreProduct,
         'verbose|v' => \$verbose,
@@ -66,4 +68,8 @@
     $singleExpId = -1;
     print "* OPTIONAL: a single exposure ID            -e <expID>           (default = none)\n";
+}
+if (!defined $lastExpId) {
+    $lastExpId = 0;
+    print "* OPTIONAL: process from last exp ID        -x <expID>           (default = $lastExpId)\n";
 }
 if (!defined $datastoreProduct) {
@@ -107,5 +113,5 @@
 else {
 
-    if (!$gpc1Db->getExposureListFromDvoDb($dvoDb, \$exposures)) {exit;}
+    if (!$gpc1Db->getExposureListFromDvoDb($dvoDb, \$exposures, $lastExpId)) {exit;}
 }
 
