Index: /trunk/FACT++/src/scheduler.cc
===================================================================
--- /trunk/FACT++/src/scheduler.cc	(revision 19478)
+++ /trunk/FACT++/src/scheduler.cc	(revision 19479)
@@ -576,5 +576,5 @@
             Info("A source with the same name (key="+to_string(source_key)+") was found in the Source table.");
         }
-
+/*
         if (source_key<0)
         {
@@ -598,5 +598,5 @@
 
         }
-
+*/
         Out() << Time()-stopwatch << endl;
 
@@ -784,4 +784,30 @@
         Info("Source will be scheduled.");
 
+        if (source_key<0)
+        {
+            const string query =
+                "INSERT INTO Source\n"
+                " (fSourceName, fRightAscension, fDeclination, fWobbleAngle0, fWobbleAngle1, fSourceTypeKey, fIsToO) VALUES\n"
+                " ('"+name+"', "+to_string(ra/15.)+", "+to_string(dec)+", "+to_string(wobble_angle-90)+", "+to_string(wobble_angle+90)+", 1, 1)";
+
+            if (!fDryRun)
+            {
+                auto q = fConnection.query(query);
+                q.execute();
+                Info(q.info());
+
+                source_key = q.insert_id();
+
+                Info(string(fDryRun?"[dry-run] ":"")+"The new source got the key "+to_string(source_key));
+            }
+            else
+                Out() << query << endl;
+
+        }
+
+        Out() << Time()-stopwatch << endl;
+
+        // ====================================================================
+
         vector<string> insert;
 
