Index: trunk/ippTools/src/disttool.c
===================================================================
--- trunk/ippTools/src/disttool.c	(revision 28941)
+++ trunk/ippTools/src/disttool.c	(revision 28959)
@@ -329,4 +329,21 @@
         // stack stage doesn't require magic
         no_magic = true;
+    } else if (!strcmp(stage, "sky")) {
+        magicRunType = "staticskyRun";
+        query = pxDataGet("disttool_definebyquery_sky.sql");
+        if (!query) {
+            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
+            psFree(where);
+            return false;
+        }
+
+        if (label) {
+            psStringAppend(&query, " AND (staticskyRun.label = '%s')", label);
+        }
+        if (dist_group) {
+            psStringAppend(&query, " AND (sticskyRun.dist_group = '%s')", dist_group);
+        }
+        // (static)sky stage doesn't require magic
+        no_magic = true;
     } else if (!strcmp(stage, "SSdiff")) {
       magicRunType = "diffRun";
Index: trunk/ippTools/src/staticskytool.c
===================================================================
--- trunk/ippTools/src/staticskytool.c	(revision 28941)
+++ trunk/ippTools/src/staticskytool.c	(revision 28959)
@@ -727,5 +727,4 @@
 bool exportrunMode(pxConfig *config)
 {
-# if (0)
   typedef struct ExportTable {
     char tableName[80];
@@ -737,5 +736,5 @@
   PS_ASSERT_PTR_NON_NULL(config, NULL);
 
-  PXOPT_LOOKUP_S64(det_id, config->args, "-stack_id", true,  false);
+  PXOPT_LOOKUP_S64(det_id, config->args, "-sky_id", true,  false);
   PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
   PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
@@ -753,10 +752,10 @@
   }
   psMetadata *where = psMetadataAlloc();
-  PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "==");
+  PXOPT_COPY_S64(config->args, where, "-sky_id", "sky_id", "==");
 
   ExportTable tables [] = {
-    {"stackRun", "staticskytool_export_run.sql"},
-    {"stackInputSkyfile", "staticskytool_export_input_skyfile.sql"},
-    {"stackSumSkyfile", "staticskytool_export_sum_skyfile.sql"},
+    {"staticskyRun", "staticskytool_export_run.sql"},
+    {"staticskyInput", "staticskytool_export_input.sql"},
+    {"staticskyResult", "staticskytool_export_result.sql"},
   };
 
@@ -800,6 +799,6 @@
 
     if (clean) {
-        if (!strcmp(tables[i].tableName, "stackRun")) {
-            if (!pxSetStateCleaned("stackRun", "state", output)) {
+        if (!strcmp(tables[i].tableName, "staticskyRun")) {
+            if (!pxSetStateCleaned("staticskyRun", "state", output)) {
                 psFree(output);
                 psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
@@ -821,5 +820,4 @@
     fclose (f);
 
-# endif
     return true;
 }
