Index: trunk/ippTools/src/pstamptool.c
===================================================================
--- trunk/ippTools/src/pstamptool.c	(revision 16544)
+++ trunk/ippTools/src/pstamptool.c	(revision 16596)
@@ -106,4 +106,13 @@
         return false;
     }
+    psString outProduct = psMetadataLookupStr(&status, config->args, "-out_product");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to looku value for -out_product");
+        return false;
+    }
+    if (!outProduct) {
+        psError(PS_ERR_UNKNOWN, true, "-out_product is required");
+        return false;
+    }
 
     psString lastFileset = psMetadataLookupStr(&status, config->args, "-last_fileset");
@@ -115,7 +124,8 @@
     if (!pstampDataStoreInsert(config->dbh,
             0,
-            uri,
+            state,
             lastFileset,
-            state
+            outProduct,
+            uri
         )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -128,7 +138,19 @@
 static bool datastoreMode(pxConfig *config)
 {
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    if (!p_psDBRunQuery(config->dbh, "SELECT * FROM pstampDataStore")) {
+    bool status = false;
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    psString ds_id = psMetadataLookupStr(&status, config->args, "-ds_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ds_id");
+        return false;
+    }
+
+    psString query = NULL;
+    psStringAppend(&query, "SELECT * FROM pstampDataStore");
+    if (ds_id) {
+        psStringAppend(&query, " WHERE ds_id = '%s'", ds_id);
+    }
+    if (!p_psDBRunQuery(config->dbh, query)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
@@ -194,5 +216,5 @@
 
     if (!state && !lastFileset) {
-        psError(PS_ERR_UNKNOWN, true, "one of -last_fileset or -state is required");
+        psError(PS_ERR_UNKNOWN, true, "at least one of -last_fileset or -state is required");
         return false;
     }
@@ -247,4 +269,13 @@
         return false;
     }
+    psString outFileset = psMetadataLookupStr(&status, config->args, "-out_fileset");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -out_fileset");
+        return false;
+    }
+    if (!outFileset) {
+        psError(PS_ERR_UNKNOWN, true, "-out_fileset is required");
+        return false;
+    }
 
     // Data Store ID is optional
@@ -259,10 +290,9 @@
 
     char *query ="INSERT INTO pstampRequest"
-                 " (state, uri, ds_id)"
-                 " VALUES( 'new', '%s', %s)";
-
-    if (!p_psDBRunQuery(config->dbh, query, uri, ds_id)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        psFree(query);
+                 " (state, uri, ds_id, outFileset)"
+                 " VALUES( 'new', '%s', %s, '%s')";
+
+    if (!p_psDBRunQuery(config->dbh, query, uri, ds_id, outFileset)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
     }
