Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 14028)
+++ trunk/ippTools/src/dettool.c	(revision 14033)
@@ -2050,21 +2050,9 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    psString query = psStringCopy(
-            "SELECT"
-            "   detInputExp.det_id,"
-            "   detRun.det_type,"
-            "   rawImfile.*,"
-            "   rawExp.camera"
-            " FROM rawImfile"
-            " JOIN detInputExp"
-            "   USING(exp_id) "
-            " JOIN rawExp"
-            "   USING(exp_id) "
-            " JOIN detRun"
-            "   ON detInputExp.det_id = detRun.det_id"
-            " WHERE"
-            "   detRun.state = 'run'"
-            "   AND detRun.mode = 'master'"
-        );
+    psString query = pxDataGet("dettool_raw.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
 
     if (config->where) {
