Index: trunk/dbconfig/add.md
===================================================================
--- trunk/dbconfig/add.md	(revision 32831)
+++ trunk/dbconfig/add.md	(revision 32832)
@@ -3,5 +3,6 @@
     add_id          S64     0       # Primary Key AUTO_INCREMENT
     stage 	    STR	    64      # what the stage is (warp, cam, diff,
-    stage_id          S64     0       # Key INDEX(add_id,cam_id) fkey(cam_id) ref camRun(cam_id)
+    stage_id          S64     0       # Key INDEX(add_id,cam_id) fkey(cam_id)    ref camRun(cam_id)
+    stage_extra1    S32	    0       
     state           STR     64      # Key
     workdir         STR     255
Index: trunk/ippScripts/scripts/addstar_run.pl
===================================================================
--- trunk/ippScripts/scripts/addstar_run.pl	(revision 32831)
+++ trunk/ippScripts/scripts/addstar_run.pl	(revision 32832)
@@ -37,5 +37,5 @@
 }
 my $minidvodb_path;
-my ( $add_id, $camera, $stage, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
+my ( $add_id, $camera, $stage, $multi_num, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
      $no_op, $redirect, $save_temps);
 GetOptions(
@@ -43,5 +43,5 @@
     'camera|c=s'        => \$camera, # Camera
     'stage|s=s'        => \$stage, # Camera
-    
+    'multi_num|w=s'    => \$multi_num, # the number for a staticskymulti (for finding cmf)
     'dbname|d=s'        => \$dbname, # Database name
     'outroot|w=s'       => \$outroot, # output file base name
@@ -114,4 +114,13 @@
     
 }
+
+if ($stage =~/staticsky_multi/) {
+    $fpaObjects =~ s/smf$/cmf/; #this should do nothing because it was already modded above
+    &my_die( "can't find the filter_num for staticsky_multi, giving up.", $add_id, $PS_EXIT_SYS_ERROR) unless (defined $multi_num);
+    my $nice_num = sprintf ("%03d", $multi_num);
+    $fpaObjects =~ s/cmf$/$nice_num.cmf/;  #this make it look for .001.cmf, etc
+ 
+}
+
 my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
 
@@ -190,7 +199,7 @@
         $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
 	    $command .= " -image" if $image_only;
-	    if ($stage = ~/staticsky/) {
+	    if ($stage =~ /staticsky/) {
 		$command .= " -accept-astrom ";
-	    }
+	    }  #careful here - this matches staticsky and staticsky_multi
         my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
 
Index: trunk/ippTasks/addstar.pro
===================================================================
--- trunk/ippTasks/addstar.pro	(revision 32831)
+++ trunk/ippTasks/addstar.pro	(revision 32832)
@@ -26,4 +26,7 @@
     active true
   end
+  task addstar.exp.load.staticsky_multi
+    active true
+  end  
   task addstar.exp.run
     active true
@@ -39,4 +42,7 @@
   end
   task addstar.exp.load.staticsky
+    active false
+  end
+  task addstar.exp.load.staticsky_multi
     active false
   end
@@ -175,4 +181,5 @@
   end
 end
+
 task	       addstar.exp.load.staticsky
   host         local
@@ -229,4 +236,61 @@
   end
 end
+
+task	       addstar.exp.load.staticsky_multi
+  host         local
+
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/addstar.exp.log
+
+  task.exec
+   # if ($LABEL:n == 0) break
+    $run = addtool -pendingexp -stage staticsky_multi
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$addstar_DB
+      $run = $run -dbname $DB:$addstar_DB
+      $addstar_DB ++
+      if ($addstar_DB >= $DB:n) set addstar_DB = 0
+    end
+    add_poll_args run
+    add_poll_labels run
+    command $run
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout addPendingExp -key add_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook addPendingExp
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup addPendingExp
+  end
+
+  # default exit status
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+
 # run the addstar script on pending exposures
 task	       addstar.exp.run
@@ -252,4 +316,5 @@
     book getword addPendingExp $pageName exp_tag -var EXP_TAG
     book getword addPendingExp $pageName add_id -var ADD_ID
+    book getword addPendingExp $pageName stage_extra1 -var STAGE_EXTRA1
     book getword addPendingExp $pageName stageroot -var STAGEROOT
     book getword addPendingExp $pageName stage -var STAGE  
@@ -285,4 +350,7 @@
 	sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID
     end
+    if ("$STAGE" == "staticsky_multi")
+	sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID
+    end
     if ("$STAGE" == "stack")
 	sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID
@@ -296,4 +364,7 @@
     if ("$REDUCTION" != "NULL")
       $run = $run --reduction $REDUCTION
+    end
+    if ("$STAGE" == "staticsky_multi")
+      $run = $run --multi_num $STAGE_EXTRA1
     end
     if ("$IMAGE_ONLY" == "T")
Index: trunk/ippTasks/survey.pro
===================================================================
--- trunk/ippTasks/survey.pro	(revision 32831)
+++ trunk/ippTasks/survey.pro	(revision 32832)
@@ -33,5 +33,5 @@
  book create SURVEY_WARP_BG
  book create SURVEY_PUBLISH
- book create SURVEY_STATICSKYSINGLE   
+ book create SURVEY_STATICSKYSINGLE 
  $haveSurveyBooks = TRUE
 end
@@ -48,5 +48,4 @@
 $SURVEY_PUBLISH_DB = 0
 $SURVEY_STATICSKYSINGLE_DB = 0
-
 $SURVEY_EXEC = 120
 $SURVEY_POLL = 10
@@ -839,4 +838,9 @@
         $run = $run -uncensored
     end
+    if ("$stage" == "staticsky_multi") 
+        #only queue uncensored staticsky (multi filter)
+        $run = $run -uncensored
+    end
+
     if ("$stage" == "stack") 
         #only queue uncensored stacks
Index: trunk/ippTools/share/Makefile.am
===================================================================
--- trunk/ippTools/share/Makefile.am	(revision 32831)
+++ trunk/ippTools/share/Makefile.am	(revision 32832)
@@ -10,4 +10,6 @@
 	addtool_find_sky_id_dvo.sql \
 	addtool_find_sky_id.sql \
+	addtool_find_sky_id_multi_dvo.sql \
+	addtool_find_sky_id_multi.sql \
 	addtool_find_stack_id_dvo.sql \
 	addtool_find_stack_id.sql \
@@ -16,8 +18,10 @@
 	addtool_find_pendingexp_stack.sql \
 	addtool_find_pendingexp_staticsky.sql \
+	addtool_find_pendingexp_staticsky_multi.sql \
 	addtool_find_pendingmergeprocess.sql \
 	addtool_find_processedexp_cam.sql \
 	addtool_find_processedexp_stack.sql \
 	addtool_find_processedexp_staticsky.sql \
+	addtool_find_processedexp_staticsky_multi.sql \
 	addtool_find_minidvodbprocessed.sql \
 	addtool_find_minidvodbrun.sql \
@@ -27,4 +31,5 @@
 	addtool_queue_stack_id.sql \
 	addtool_queue_sky_id.sql \
+	addtool_queue_sky_id_multi.sql \
 	addtool_queue_minidvodbrun.sql \
 	addtool_revertminidvodbprocessed.sql \
@@ -32,4 +37,5 @@
 	addtool_revertprocessedexp_stack.sql \
 	addtool_revertprocessedexp_staticsky.sql \
+	addtool_revertprocessedexp_staticsky_multi.sql \
 	bgtool_advancechip.sql \
 	bgtool_advancewarp.sql \
Index: trunk/ippTools/share/addtool_find_pendingexp_staticsky_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_find_pendingexp_staticsky_multi.sql	(revision 32832)
+++ trunk/ippTools/share/addtool_find_pendingexp_staticsky_multi.sql	(revision 32832)
@@ -0,0 +1,32 @@
+SELECT
+    addRun.*,
+    staticskyResult.path_base as stageroot,
+    rawExp.camera,
+    rawExp.telescope
+FROM addRun
+JOIN staticskyRun 
+    ON sky_id = stage_id
+JOIN staticskyResult
+     USING (sky_id)
+JOIN staticskyInput
+     USING (sky_id)
+JOIN stackRun
+    USING (stack_id)
+JOIN stackInputSkyfile 
+     USING(stack_id)
+JOIN warpRun using(warp_id)
+JOIN fakeRun using(fake_id)
+JOIN camRun using(cam_id)
+JOIN chipRun using(chip_id)
+JOIN rawExp using (exp_id)
+LEFT JOIN addProcessedExp using (add_id)
+LEFT JOIN addMask
+    ON addRun.label = addMask.label
+WHERE
+    staticskyRun.state = 'full'
+    AND stage = 'staticsky_multi'
+    AND ((addRun.state = 'new' AND addProcessedExp.add_id IS NULL) OR addRun.state = 'update')
+    AND addRun.dvodb IS NOT NULL
+    AND addRun.workdir IS NOT NULL
+    AND addMask.label IS NULL
+
Index: trunk/ippTools/share/addtool_find_processedexp_staticsky_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_find_processedexp_staticsky_multi.sql	(revision 32832)
+++ trunk/ippTools/share/addtool_find_processedexp_staticsky_multi.sql	(revision 32832)
@@ -0,0 +1,6 @@
+SELECT
+    addProcessedExp.*,
+    addRun.workdir
+FROM addProcessedExp
+JOIN addRun
+    USING(add_id)
Index: trunk/ippTools/share/addtool_find_sky_id_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_find_sky_id_multi.sql	(revision 32832)
+++ trunk/ippTools/share/addtool_find_sky_id_multi.sql	(revision 32832)
@@ -0,0 +1,24 @@
+SELECT
+     distinct(sky_id) as stage_id,
+     staticskyRun.*,
+    staticskyResult.num_inputs
+FROM 
+     staticskyResult
+join staticskyRun using (sky_id)
+join staticskyInput using(sky_id)
+JOIN stackRun USING(stack_id)
+
+LEFT JOIN (SELECT sky_id       AS added_sky_id,
+                  addRun.dvodb AS previous_dvodb
+           FROM addRun
+JOIN staticskyRun on sky_id = stage_id
+          ) as foo
+     ON sky_id = added_sky_id 
+     AND stage = 'staticsky_multi'
+     -- hook for qualifying the join on the previous_dvodb
+     AND %s
+WHERE
+    staticskyRun.state = 'full'
+    AND staticskyResult.quality = 0
+    AND added_exp_id IS NULL
+    -- addtool adds checks on exposure being added to the dvodb previously
Index: trunk/ippTools/share/addtool_find_sky_id_multi_dvo.sql
===================================================================
--- trunk/ippTools/share/addtool_find_sky_id_multi_dvo.sql	(revision 32832)
+++ trunk/ippTools/share/addtool_find_sky_id_multi_dvo.sql	(revision 32832)
@@ -0,0 +1,12 @@
+SELECT distinct(sky_id) as stage_id, staticskyRun.*, staticskyResult.num_inputs FROM staticskyResult
+JOIN staticskyRun USING(sky_id)
+join staticskyInput using(sky_id)
+JOIN stackRun USING(stack_id)
+
+WHERE staticskyRun.state = 'full' and staticskyResult.quality = 0
+    AND sky_id NOT IN (SELECT sky_id
+       FROM addRun
+       JOIN staticskyResult on staticskyResult.sky_id = addRun.stage_id
+       JOIN staticskyRun USING(sky_id)
+       WHERE addRun.stage = 'staticsky_multi' AND %s
+      )
Index: trunk/ippTools/share/addtool_queue_cam_id.sql
===================================================================
--- trunk/ippTools/share/addtool_queue_cam_id.sql	(revision 32831)
+++ trunk/ippTools/share/addtool_queue_cam_id.sql	(revision 32832)
@@ -4,4 +4,5 @@
 	'cam',		-- stage
         cam_id,         -- stage_id
+	%d,		-- stage_extra1
         '%s',           -- state
         '%s',           -- workdir
Index: trunk/ippTools/share/addtool_queue_sky_id.sql
===================================================================
--- trunk/ippTools/share/addtool_queue_sky_id.sql	(revision 32831)
+++ trunk/ippTools/share/addtool_queue_sky_id.sql	(revision 32832)
@@ -4,4 +4,5 @@
         'staticsky',		-- stage
         sky_id,         -- stage_id
+	%d,		-- stage_extra1
         '%s',           -- state
         '%s',           -- workdir
Index: trunk/ippTools/share/addtool_queue_sky_id_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_queue_sky_id_multi.sql	(revision 32832)
+++ trunk/ippTools/share/addtool_queue_sky_id_multi.sql	(revision 32832)
@@ -0,0 +1,22 @@
+INSERT INTO addRun
+    SELECT
+        0,              -- add_id
+        'staticsky_multi',		-- stage
+        sky_id,         -- stage_id
+	%d,		-- stage_extra1
+        '%s',           -- state
+        '%s',           -- workdir
+	'%s',           -- workdir_state
+        '%s',           -- reduction
+        '%s',           -- label
+        '%s',           -- data_group
+        '%s',           -- dvodb 
+        '%s',           -- note
+	%d,		-- image_only
+	%d,		-- minidvodb
+	'%s',           -- minidvodb_group 
+ 	'%s'	        -- minidvodb_name
+    FROM staticskyRun
+    WHERE
+        staticskyRun.state = 'full'
+        AND staticskyRun.sky_id = %lld
Index: trunk/ippTools/share/addtool_queue_stack_id.sql
===================================================================
--- trunk/ippTools/share/addtool_queue_stack_id.sql	(revision 32831)
+++ trunk/ippTools/share/addtool_queue_stack_id.sql	(revision 32832)
@@ -4,4 +4,5 @@
         'stack',		-- stage
         stack_id,         -- stage_id
+	%d,		  --stage_extra1
         '%s',           -- state
         '%s',           -- workdir
Index: trunk/ippTools/share/addtool_revertprocessedexp_staticsky_multi.sql
===================================================================
--- trunk/ippTools/share/addtool_revertprocessedexp_staticsky_multi.sql	(revision 32832)
+++ trunk/ippTools/share/addtool_revertprocessedexp_staticsky_multi.sql	(revision 32832)
@@ -0,0 +1,7 @@
+DELETE FROM addProcessedExp
+USING addProcessedExp, addRun
+WHERE
+    addRun.add_id = addProcessedExp.add_id
+    AND addProcessedExp.fault != 0
+    AND addRun.state = 'new'
+    AND addRun.stage = 'staticsky_multi'
Index: trunk/ippTools/src/addtool.c
===================================================================
--- trunk/ippTools/src/addtool.c	(revision 32831)
+++ trunk/ippTools/src/addtool.c	(revision 32832)
@@ -143,5 +143,11 @@
     pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     }
-    
+        if (strcmp(stage, "staticsky_multi")== 0) {
+
+    pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
+    pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
+    PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
+    //no filter here
+    }
     if (!psListLength(where->list)) {
         psFree(where);
@@ -237,5 +243,19 @@
     }
 
-
+    if (strcmp(stage,"staticsky_multi") == 0) {
+      if (dvodb ) {
+	psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
+        // find the cam_id of all the exposures that we want to queue up.
+        bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql");
+	// user supplied dvodb
+	psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
+    } else {
+      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
+        // find the cam_id of all the exposures that we want to queue up.
+        bare_query = pxDataGet("addtool_find_sky_id_multi.sql");
+        // inherit dvodb from camRun, avoid matching NULL
+        psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
+    }
+    }
 
     if (!bare_query) {
@@ -292,5 +312,7 @@
 	psStringAppend(&query, " GROUP BY stack_id");
       }
-
+    if (strcmp(stage,"staticsky_multi") == 0) {
+      psStringAppend(&query, " GROUP BY sky_id");  //some reason it needs this
+      }
 
 
@@ -405,4 +427,43 @@
     }
     }
+    if (strcmp(stage,"staticsky_multi") == 0) {
+    for (long i = 0; i < psArrayLength(output); i++) {
+        psMetadata *md = output->data[i];
+	bool status = false;
+	psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
+	  return false;
+	}
+	if (num_inputs < 0) {
+	  psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");
+	  return false;
+	}
+
+	staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
+	
+        if (!row) {
+            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
+            psFree(output);
+            return false;
+        }
+
+        if (!dvodb) {  //there's no staticsky.dvodb
+            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
+            psFree(output);
+            return false;
+        }
+        if (!workdir && !row->workdir) {
+            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
+            psFree(output);
+            return false;
+        }
+
+        psFree(row);
+    }
+    }
+
+
+
 
     // start a transaction so we don't end up with an exp without any associted
@@ -438,4 +499,5 @@
 			       stage,
                                stage_id,
+			       0,
                                workdir     ? workdir   : row->workdir,
                                reduction   ? reduction : row->reduction,
@@ -479,4 +541,5 @@
 			       stage,
                                stage_id,
+			       0,
                                workdir     ? workdir   : row->workdir,
                                reduction   ? reduction : row->reduction,
@@ -520,4 +583,5 @@
 			       stage,
                                stage_id,
+			       0,
                                workdir     ? workdir   : row->workdir,
                                reduction   ? reduction : row->reduction,
@@ -544,4 +608,57 @@
       }
 
+    if (strcmp(stage,"staticsky_multi") == 0) {
+    for (long i = 0; i < psArrayLength(output); i++) {
+        psMetadata *md = output->data[i];
+	psS64 stage_id =0; 
+	bool status = false;
+	psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
+	  return false;
+	}
+	staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
+	stage_id = row->sky_id;
+	
+        if (!row) {
+            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
+            psFree(output);
+            return false;
+        }
+
+        // queue the exp
+	for (int filter_id = 0; filter_id < num_inputs; filter_id++) {  
+        if (!pxaddQueueByCamID(config,
+			       stage,
+                               stage_id,
+			       filter_id,
+                               workdir     ? workdir   : row->workdir,
+                               reduction   ? reduction : row->reduction,
+                               label       ? label     : row->label,
+                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
+                               dvodb       ? dvodb     : NULL,
+                               note        ? note      : NULL,
+                               image_only,
+                               minidvodb,
+                               minidvodb_group,
+                               minidvodb_name
+        )) {
+            if (!psDBRollback(config->dbh)) {
+                psError(PS_ERR_UNKNOWN, false, "database error sfg");
+            }
+            psError(PS_ERR_UNKNOWN, false,
+                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
+            psFree(row);
+            psFree(output);
+            return false;
+        }
+	}
+        psFree(row);
+    }
+      }
+
+
+
+
     psFree(output);
 
@@ -585,4 +702,7 @@
     }
     if (strcmp(stage, "staticsky")==0) {
+    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
+    }
+    if (strcmp(stage, "staticsky_multi")==0) {
     query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     }
@@ -626,5 +746,8 @@
     query = pxDataGet("addtool_find_pendingexp_staticsky.sql");
     }
-
+    if (strcmp(stage, "staticsky_multi")==0) { 
+    query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql");
+    }
+    
 
     if (!query) {
@@ -648,5 +771,8 @@
       psStringAppend(&query, " GROUP BY %s", "sky_id");
     }
-
+    if (strcmp(stage, "staticsky_multi") == 0) {
+      //this group by is needed to join against all the warps (to get camera)
+      psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1");
+    }
     // treat limit == 0 as "no limit"
     if (limit) {
@@ -838,4 +964,8 @@
     query = pxDataGet("addtool_find_processedexp_staticsky.sql");
     }
+    if (strcmp (stage,"staticsky_multi") == 0) {
+    query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
+    }
+
    
     if (!query) {
@@ -948,4 +1078,10 @@
 	 query = pxDataGet("addtool_revertprocessedexp_staticsky.sql");
       }
+   if (strcmp(stage, "staticsky_multi") == 0) {
+	 query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
+      }
+
+
+     
       if (!query) {
             // rollback
Index: trunk/ippTools/src/flatcorr.c
===================================================================
--- trunk/ippTools/src/flatcorr.c	(revision 32831)
+++ trunk/ippTools/src/flatcorr.c	(revision 32832)
@@ -666,4 +666,5 @@
 		"cam",
                 row->cam_id,
+		0,
                 row->workdir,
                 row->reduction,
Index: trunk/ippTools/src/pxadd.c
===================================================================
--- trunk/ippTools/src/pxadd.c	(revision 32831)
+++ trunk/ippTools/src/pxadd.c	(revision 32832)
@@ -131,4 +131,5 @@
 		       char *stage,
                        psS64 stage_id,
+		       psS32 stage_extra1,
                        char *workdir,
                        char *reduction,
@@ -159,4 +160,8 @@
         psMemSetPersistent(query, true);
       }
+      if (strcmp(stage,"staticsky_multi") == 0) {
+	query = pxDataGet("addtool_queue_sky_id_multi.sql");
+        psMemSetPersistent(query, true);
+      }
         if (!query) {
             psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
@@ -170,4 +175,5 @@
     // on 32/64
     if (!p_psDBRunQueryF(config->dbh, query,
+			 stage_extra1 ? stage_extra1 : 0,
 			 "new", // state
                          workdir  ? workdir   : "NULL",
Index: trunk/ippTools/src/pxadd.h
===================================================================
--- trunk/ippTools/src/pxadd.h	(revision 32831)
+++ trunk/ippTools/src/pxadd.h	(revision 32832)
@@ -33,4 +33,5 @@
 		       char *stage,
 		       psS64 stage_id,
+		       psS32 stage_extra1,
 		       char *workdir,
 		       char *reduction,
