]> andersk Git - moira.git/blobdiff - backup/rest_db.dc
added subnets
[moira.git] / backup / rest_db.dc
index 21bd70705b3266a2604bd861eeb88787e59ad7bf..b0a01a6fa4d40257f27c20596d9ed3904d80ed18 100644 (file)
@@ -17,6 +17,7 @@ static char *rcsid_rest_db_qc = "$Header$";
 #include <stdio.h>
 #include <ctype.h>
 #include <mit-copyright.h>
+EXEC SQL INCLUDE sqlca;
 #include "dump_db.h"
 
 
@@ -27,19 +28,34 @@ main(argc, argv)
 {
     char buf[BUFSIZ];
     char *prefix;
-    
+    EXEC SQL BEGIN DECLARE SECTION;
+    char *db;
+    EXEC SQL END DECLARE SECTION;
+
+    if (argc != 2) {
+       fprintf(stderr, "Usage: %s database\n", argv[0]);
+       exit(1);
+    }
+    db = argv[1];
+
     if (!yes_or_no("Do you *REALLY* want to wipe the SMS database?")) {
        printf("I didn't think so\n");
        exit(1);
     }
-    if (!yes_or_no("Have you initialized an empty database named smstemp?")) {
+    sprintf(buf, "Have you initialized an empty database named %s?", db);
+    if (!yes_or_no(buf)) {
        printf("You should have\n");
        exit(1);
     }
     
     printf("Opening database: ");
     (void) fflush(stdout);
-##     ingres smstemp
+    EXEC SQL CONNECT :db;
+    if (sqlca.sqlcode != 0) {
+       com_err(argv[0], 0, "Ingres database open failed");
+       exit(1);
+    }
+    EXEC SQL SET AUTOCOMMIT ON;
 
     printf(" done\n");
 
@@ -56,7 +72,8 @@ main(argc, argv)
     }
     do_restores(prefix);
     printf("Restore complete\n");
-##     exit
+    EXEC SQL COMMIT;
+    EXEC SQL DISCONNECT;
     exit(0);
     /*NOTREACHED*/
 }
@@ -181,6 +198,8 @@ FILE *open_file(prefix, suffix)
     int fd;
     FILE *f;
     
+    EXEC SQL COMMIT WORK;
+
     (void) strcpy(name, prefix);
     (void) strcat(name, suffix);
 
This page took 0.032655 seconds and 4 git commands to generate.