Copy the database rows in the same order as the original database.
authorrich <rich>
Mon, 11 Sep 2006 09:58:43 +0000 (09:58 +0000)
committerrich <rich>
Mon, 11 Sep 2006 09:58:43 +0000 (09:58 +0000)
tools/copy_host.ml

index aef72a9..e1e0a0b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Use 'copy_host --help' for usage.
  *
- * $Id: copy_host.ml,v 1.1 2006/09/09 15:08:08 rich Exp $
+ * $Id: copy_host.ml,v 1.2 2006/09/11 09:58:43 rich Exp $
  *)
 
 open Printf
@@ -179,7 +179,7 @@ let dryrun = !dryrun
 
 (* Get column names from a table. *)
 let columns dbh table_name =
-  let query = "select * from " ^ table_name in
+  let query = "select * from " ^ table_name ^ " order by 1" in
   let name = "columns" in
   PGOCaml.prepare dbh ~query ~name ();
   let columns =
@@ -195,7 +195,8 @@ let select_all dbh table_name where_clause =
   let query = "select * from " ^ table_name ^
     (match where_clause with
      | "" -> ""
-     | where_clause -> " where " ^ where_clause) in
+     | where_clause -> " where " ^ where_clause) ^ 
+    " order by 1" in
   let name = "selectall" in
   PGOCaml.prepare dbh ~query ~name ();
   let columns =