Index: trunk/pstamp/scripts/pstampparse.pl
===================================================================
--- trunk/pstamp/scripts/pstampparse.pl	(revision 25068)
+++ trunk/pstamp/scripts/pstampparse.pl	(revision 25075)
@@ -96,4 +96,21 @@
 my_die("wrong EXTVER $extver found in $request_file_name", $PS_EXIT_PROG_ERROR) if ($extver ne "1");
 
+{
+    my $command = "$pstamptool -listreq  -name $req_name";
+    $command .= " -dbname $dbname" if $dbname;
+    $command .= " -dbserver $dbserver" if $dbserver;
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    my $exitStatus = $error_code >> 8;
+    if ($success) {
+        # -listreq succeeded duplicate request name
+        insertFakeJobForRow(undef, 0, $PSTAMP_DUP_REQUEST);
+        exit 0;
+    } elsif ($exitStatus ne $PS_EXIT_DATA_ERROR) {
+        # wrong error code something else is wrong
+        my_die("$command failed", $exitStatus);
+    }
+}
+
 if ($req_id and !$no_update) {
     # update the database with the request name. This will be used as the
@@ -152,5 +169,5 @@
     if (!$proj_hash) {
         print STDERR "project $project not found\n"  if $verbose;
-        insertFakeJobForRow($row, 1, 46);
+        insertFakeJobForRow($row, 1, $PSTAMP_UNKNOWN_PRODUCT);
         $num_jobs++;
         next;
@@ -173,5 +190,5 @@
     if (!$skycenter and !$search_component) {
         print STDERR "COMPONENT must be specified for pixel coordinate ROI\n" if $verbose;
-        insertFakeJobForRow($row, 1, 45);
+        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
         $num_jobs++;
         next;
@@ -182,5 +199,5 @@
     if (($job_type eq "stamp") and ! validROI($row)) {
         print STDERR "invalid ROI for row $rownum\n" if $verbose;
-        insertFakeJobForRow($row, 1, 46);
+        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
         $num_jobs++;
         next;
@@ -221,10 +238,10 @@
         if (!$skycenter) {
             print STDERR "center must be specified in sky coordintes for bycoord" if $verbose;
-            insertFakeJobForRow($row, 1, 46);
+            insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
             $num_jobs++;
             next;
         }
         print STDERR "lookup bycoord is not yet implemented" if $verbose;
-        insertFakeJobForRow($row, 1, 47);
+        insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
         $num_jobs++;
         next;
@@ -250,5 +267,5 @@
 if (($mode eq "queue_jobs") and ($num_jobs eq 0)) {
     print STDERR "no jobs created for $req_name\n" if $verbose;
-    insertFakeJobForRow(undef, 1, 41);
+    insertFakeJobForRow(undef, 0, $PSTAMP_UNKNOWN_ERROR);
 }
 
@@ -272,5 +289,5 @@
     if ( $numComponents == 0 ) {
         print STDERR "no jobs for row $rownum\n" if $verbose;
-        insertFakeJobForRow($row, 1, 44);
+        insertFakeJobForRow($row, 1, $PSTAMP_NO_JOBS_QUEUED);
         return 1;
     }
@@ -319,5 +336,5 @@
             # for now assume yes.
 
-            insertFakeJobForRow($row, $job_num, 43);
+            insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED);
 
             next;
@@ -417,5 +434,5 @@
         print STDERR "get_image jobs not implemented yet" if $verbose;
         foreach my $row (@$rowList) {
-            insertFakeJobForRow($row, 1, 47);
+            insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
             $num_jobs++;
         }
@@ -425,5 +442,5 @@
             # the status back to the requestor
             foreach my $row (@$rowList) {
-                insertFakeJobForRow($row, 1, 42);
+                insertFakeJobForRow($row, 1, $PSTAMP_NO_IMAGE_MATCH);
                 $num_jobs++;
             }
@@ -605,5 +622,6 @@
         # if first row has no component all of the images will be retrieved, so
         # the fact that this row has a component is ok. Fall through to return 1
-        # return 0;
+        # XXX Nope that doesn't work (yet)
+        return 0;
     }
 
