Index: trunk/ippTools/share/addtool_find_diff_id_dvo.sql
===================================================================
--- trunk/ippTools/share/addtool_find_diff_id_dvo.sql	(revision 37587)
+++ trunk/ippTools/share/addtool_find_diff_id_dvo.sql	(revision 37709)
@@ -4,7 +4,4 @@
 JOIN diffSkyfile using (diff_id, skycell_id) 
 JOIN diffRun using (diff_id)
-
-
-diffRun JOIN diffSkyfile using (diff_id)
 
 WHERE diffRun.state = 'full' and diffSkyfile.quality = 0
Index: trunk/ippTools/share/addtool_find_pendingexp_diff.sql
===================================================================
--- trunk/ippTools/share/addtool_find_pendingexp_diff.sql	(revision 37587)
+++ trunk/ippTools/share/addtool_find_pendingexp_diff.sql	(revision 37709)
@@ -2,6 +2,6 @@
     addRun.*,
     diffSkyfile.path_base as stageroot,
-    "NULL",
-    "NULL"
+    'GPC1' as camera,
+    'PS1' as telescope
 FROM addRun
 JOIN diffInputSkyfile
Index: trunk/ippTools/share/addtool_find_pendingexp_ff.sql
===================================================================
--- trunk/ippTools/share/addtool_find_pendingexp_ff.sql	(revision 37587)
+++ trunk/ippTools/share/addtool_find_pendingexp_ff.sql	(revision 37709)
@@ -1,7 +1,5 @@
    SELECT
     addRun.*,
-    fullForceResult.path_base as stageroot,
-    "NULL",
-    "NULL"
+    fullForceResult.path_base as stageroot
 FROM addRun
 JOIN fullForceResult
Index: trunk/ippTools/share/addtool_queue_diff_id.sql
===================================================================
--- trunk/ippTools/share/addtool_queue_diff_id.sql	(revision 37587)
+++ trunk/ippTools/share/addtool_queue_diff_id.sql	(revision 37709)
@@ -4,5 +4,5 @@
         'diff',		-- stage
         diff_id,        -- stage_id
-        diff_skyfile_id, -- stage_extra1
+        %d, -- stage_extra1
         '%s',           -- state
         '%s',           -- workdir
@@ -17,8 +17,7 @@
 	'%s',           -- minidvodb_group 
  	'%s'	        -- minidvodb_name
-    FROM diffInputSkyfile 
-    JOIN diffSkyfile using (diff_id, skycell_id)
-    JOIN diffRun using (diff_id)
+    FROM diffRun
     WHERE
-        diffRun.state = 'full' AND
+        diffRun.state = 'full' 
         AND diffRun.diff_id = %lld
+        
Index: trunk/ippTools/share/addtool_queue_ff_id.sql
===================================================================
--- trunk/ippTools/share/addtool_queue_ff_id.sql	(revision 37587)
+++ trunk/ippTools/share/addtool_queue_ff_id.sql	(revision 37709)
@@ -4,5 +4,5 @@
         'fullforce',		-- stage
         ff_id,         -- stage_id
-	warp_id,	-- stage_extra1
+        %d,	       -- stage_extra1
         '%s',           -- state
         '%s',           -- workdir
@@ -17,6 +17,5 @@
 	'%s',           -- minidvodb_group 
  	'%s'	        -- minidvodb_name
-    FROM fullForceResult
-    JOIN fullForceRun using (ff_id)
+    FROM fullForceRun
     WHERE
         fullForceRun.state = 'full'
Index: trunk/ippTools/src/addtool.c
===================================================================
--- trunk/ippTools/src/addtool.c	(revision 37587)
+++ trunk/ippTools/src/addtool.c	(revision 37709)
@@ -373,9 +373,9 @@
       //needs to be checked HAF xxx
       if (strcmp(stage,"diff") == 0) {
-	psStringAppend(&query, " GROUP BY diff_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
+	psStringAppend(&query, " GROUP BY diff_id, diff_skyfile_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
       }
       //needs to be checked HAF xxx
       if (strcmp(stage,"fullforce") == 0) {
-	psStringAppend(&query, " GROUP BY ff_id, skycal_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
+	psStringAppend(&query, " GROUP BY ff_id, warp_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
       }
 
@@ -535,11 +535,12 @@
 
     if (strcmp(stage,"diff") == 0) {
+      
       for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *md = output->data[i];
 
         diffRunRow *row = diffRunObjectFromMetadata(md);
-
+	
         if (!row) {
-	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
+	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");
 	  psFree(output);
 	  return false;
@@ -568,5 +569,5 @@
 
         if (!row) {
-	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
+	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
 	  psFree(output);
 	  return false;
@@ -784,10 +785,18 @@
    
     if (strcmp(stage,"diff") == 0) {
+      
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *md = output->data[i];
 	psS64 stage_id =0; 
-	
-		  diffRunRow *row = diffRunObjectFromMetadata(md);
-	  stage_id = row->diff_id;
+	//	psS64 stage_extra1 = 0;
+	diffRunRow *row = diffRunObjectFromMetadata(md);
+	stage_id = row->diff_id;
+	bool status = false;
+	psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");
+	  return false;
+	}
+
 	
         if (!row) {
@@ -796,10 +805,10 @@
             return false;
         }
-
+	
         // queue the exp
         if (!pxaddQueueByCamID(config,
 			       stage,
                                stage_id,
-			       0,
+			       stage_extra1,
                                workdir     ? workdir   : row->workdir,
                                reduction   ? reduction : row->reduction,
@@ -831,7 +840,13 @@
 	psS64 stage_id =0; 
 	
-		  fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
-	  stage_id = row->ff_id;
-	
+	fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
+	stage_id = row->ff_id;
+	bool status = false;
+	psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
+	  return false;
+	}
+
         if (!row) {
             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
@@ -844,5 +859,5 @@
 			       stage,
                                stage_id,
-			       0,
+			       stage_extra1,
                                workdir     ? workdir   : row->workdir,
                                reduction   ? reduction : row->reduction,
