Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 12123)
+++ trunk/ippTools/src/dettool.c	(revision 12131)
@@ -25,4 +25,6 @@
 #include <string.h>
 #include <stdlib.h>
+#include <stdint.h>
+
 #include <ippdb.h>
 
@@ -70,5 +72,4 @@
 static bool register_detrend_imfileMode(pxConfig *config);
 
-static bool convertDetIdToStr(psArray *mds);
 static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile);
 static  detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile);
@@ -598,7 +599,6 @@
     }
 
-    // convert det_id to a str externally
-    if (!convertDetIdToStr(detRuns)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string");
+    if (!convertIdToStr(detRuns)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
         psFree(detRuns);
         return false;
@@ -616,4 +616,5 @@
 }
 
+#if 0
 // This function is used to convert the det_id from an int, as it is used
 // internally, to be a string for external use.  The rational being that we may
@@ -640,4 +641,5 @@
     return true;
 }
+#endif
 
 static bool definebyqueryMode(pxConfig *config)
@@ -1243,5 +1245,5 @@
 
     // convert det_id to a string externaly
-    if (!convertDetIdToStr(detRuns)) {
+    if (!convertIdToStr(detRuns)) {
         psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string");
         psFree(detRuns);
@@ -1281,5 +1283,5 @@
     {
         psMetadata *where = psMetadataAlloc();
-        psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", (psS32)atoi(det_id));
+        psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", (psS64)atoll(det_id));
         detRuns = detRunSelectRowObjects(config->dbh, where, 0);
         psFree(where);
@@ -1291,5 +1293,5 @@
     // sanity check the result... we should have only found one det_id
     if (psArrayLength(detRuns) != 1) {
-        psAbort("found more then one detRun matching det_id %d(this should not happen)", (psS32)atoi(det_id));
+        psAbort("found more then one detRun matching det_id %" PRId64 " (this should not happen)", (psS64)atoll(det_id));
         return false;                   // unreachable
     }
@@ -1624,5 +1626,5 @@
     psFree(time_filter);
 
-    if (!p_psDBRunQuery(config->dbh, query, (psS32)newDet_id, (psS32)atoi(det_id))) {
+    if (!p_psDBRunQuery(config->dbh, query, (psS64)newDet_id, (psS64)atoll(det_id))) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(query);
@@ -1666,7 +1668,7 @@
 
     // convert det_id to a string externaly
-    if (!convertDetIdToStr(newDetRuns)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string");
-        psFree(newDetRuns);
+    if (!convertIdToStr(detRuns)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(detRuns);
         return false;
     }
@@ -1701,6 +1703,6 @@
 
     // convert det_id to a string externaly
-    if (!convertDetIdToStr(runs)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string");
+    if (!convertIdToStr(runs)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
         psFree(runs);
         return false;
@@ -1784,6 +1786,6 @@
 
     // convert det_id to a string externaly
-    if (!convertDetIdToStr(output)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string");
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
         psFree(output);
         return false;
@@ -2907,5 +2909,5 @@
     psMetadata *where = psMetadataAlloc();
     if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
-            (psS32)atoi(det_id))) {
+            (psS64)atoll(det_id))) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
         psFree(where);
@@ -4870,5 +4872,5 @@
             return false;
         }
-        if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", (psS32)atoi(det_id))) {
+        if (!psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", (psS64)atoll(det_id))) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");
             psFree(where);
@@ -6332,5 +6334,5 @@
             0.0,        // solang max
             label,      // label
-            atoi(parent)
+            (psS64)atoll(parent)
     )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -6435,5 +6437,5 @@
     // the det_id is valid
     if (!detNormalizedImfileInsert(config->dbh,
-            (psS32)atoi(det_id),
+            (psS64)atoll(det_id),
             0,  // the iteration is fixed at 0
             class_id,
