Index: trunk/MagicSoft/Mars/msql/MSQLMagic.cc
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9039)
+++ trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9195)
@@ -33,4 +33,6 @@
 #include "MSQLMagic.h"
 
+#include <stdlib.h> // atoi (Ubuntu 8.10)
+
 #include <iostream>
 
Index: trunk/MagicSoft/Mars/msql/MSQLServer.cc
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 9039)
+++ trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 9195)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.16 2008-07-05 18:57:35 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.17 2008-12-21 18:09:49 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -58,4 +58,7 @@
 #include <TBrowser.h>
 
+#include <TObjString.h>
+#include <TObjArray.h>
+
 ClassImp(MSQLServer);
 
@@ -781,5 +784,5 @@
 // Return the name of the (first) column with a primary key
 //
-TString MSQLServer::GetPrimaryKey(const char *table)
+TString MSQLServer::GetPrimaryKeys(const char *table)
 {
     TSQLResult *res = GetColumns(table);
@@ -787,5 +790,6 @@
         return "";
 
-    TString rc;
+    TObjArray arr;
+    arr.SetOwner();
 
     TSQLRow *row = 0;
@@ -794,13 +798,18 @@
         const TString key = (*row)[3];
         if (key=="PRI")
-        {
-            if (!rc.IsNull())
-                rc += ", ";
-            rc += (*row)[0];
-        }
+            arr.Add(new TObjString((*row)[0]));
         delete row;
     }
-
     delete res;
+
+    arr.Sort();
+
+    TString rc;
+    for (int i=0; i<arr.GetEntries(); i++)
+    {
+        if (i>0)
+            rc += ", ";
+        rc += arr[i]->GetName();
+    }
     return rc;
 }
@@ -849,5 +858,5 @@
 
         // Now get the primary key of the table to be joined
-        const TString prim = GetPrimaryKey(tab);
+        const TString prim = GetPrimaryKeys(tab);
         if (prim.IsNull())
             continue;
Index: trunk/MagicSoft/Mars/msql/MSQLServer.h
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 9039)
+++ trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 9195)
@@ -123,5 +123,5 @@
 
     TString     GetEntry(const char *where, const char *col=0, const char *table=0) const;
-    TString     GetPrimaryKey(const char *table);
+    TString     GetPrimaryKeys(const char *table);
     TString     GetJoins(const char *table, const TString text);
 
