Index: trunk/ippTools/src/pxinject.c
===================================================================
--- trunk/ippTools/src/pxinject.c	(revision 14018)
+++ trunk/ippTools/src/pxinject.c	(revision 14023)
@@ -80,29 +80,29 @@
 
     bool status = false;
-    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
-        return false;
-    }
-    if (!exp_id) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
-        return false;
-    }
-    psString camera = psMetadataLookupStr(&status, config->args, "-inst");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst");
-        return false;
-    }
-    if (!camera) {
-        psError(PS_ERR_UNKNOWN, true, "-inst is required");
-        return false;
-    }
-    psString telescope = psMetadataLookupStr(&status, config->args, "-telescope");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -telescope");
-        return false;
-    }
-    if (!telescope) {
-        psError(PS_ERR_UNKNOWN, true, "-telescope is required");
+    psString tmp_exp_name = psMetadataLookupStr(&status, config->args, "-tmp_exp_name");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tmp_exp_name");
+        return false;
+    }
+    if (!tmp_exp_name) {
+        psError(PS_ERR_UNKNOWN, true, "-tmp_exp_name is required");
+        return false;
+    }
+    psString tmp_camera = psMetadataLookupStr(&status, config->args, "-tmp_inst");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tmp_inst");
+        return false;
+    }
+    if (!tmp_camera) {
+        psError(PS_ERR_UNKNOWN, true, "-tmp_inst is required");
+        return false;
+    }
+    psString tmp_telescope = psMetadataLookupStr(&status, config->args, "-tmp_telescope");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tmp_telescope");
+        return false;
+    }
+    if (!tmp_telescope) {
+        psError(PS_ERR_UNKNOWN, true, "-tmp_telescope is required");
         return false;
     }
@@ -127,16 +127,10 @@
     }
 
-    psString exp_tag = pxGenExpTag(config, exp_id);
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-
     if (!newExpInsert(config->dbh,
-                exp_tag,
-                exp_id,
+                0x0, // exp_id
+                tmp_exp_name,
                 "reg", // state
-                camera,
-                telescope,
+                tmp_camera,
+                tmp_telescope,
                 imfiles,
                 workdir,
@@ -145,16 +139,17 @@
         ) {
         psError(PS_ERR_UNKNOWN, false, "database error");
-        psFree(exp_tag);
-        return false;
-    }
+        return false;
+    }
+
+    psS64 lastInsertID = psDBLastInsertID(config->dbh);
+    psString exp_id = psDBIntToString(lastInsertID);
 
     psMetadata *md = psMetadataAlloc();
-    if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, exp_tag)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+    if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_id", 0, NULL, exp_id)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
         psFree(md);
-        psFree(exp_tag);
-        psFree(md);
-    }
-    psFree(exp_tag);
+        psFree(exp_id);
+    }
+    psFree(exp_id);
 
     bool simple = false;
@@ -186,11 +181,11 @@
 
     bool status = false;
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
-        return false;
-    }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
         return false;
     }
@@ -206,11 +201,11 @@
     }
 #endif
-    psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
-        return false;
-    }
-    if (!class_id) {
-        psError(PS_ERR_UNKNOWN, true, "-class_id is required");
+    psString tmp_class_id = psMetadataLookupStr(&status, config->args, "-tmp_class_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tmp_class_id");
+        return false;
+    }
+    if (!tmp_class_id) {
+        psError(PS_ERR_UNKNOWN, true, "-tmp_class_id is required");
         return false;
     }
@@ -226,5 +221,5 @@
 
     // insert with error flag state set to 0 (no errors)
-    if (!newImfileInsert(config->dbh, exp_tag, class_id, uri)) {
+    if (!newImfileInsert(config->dbh, (psS64)atoll(exp_id), tmp_class_id, uri)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
@@ -240,11 +235,11 @@
 
     bool status = false;
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
-        return false;
-    }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
         return false;
     }
@@ -262,5 +257,5 @@
     if (state) {
         // set detRun.state to state
-        return pxnewExpSetState(config, exp_tag, state);
+        return pxnewExpSetState(config, exp_id, state);
     }
 
