]> andersk Git - moira.git/blobdiff - dbck/dbck.dc
DBMS=ORACLE
[moira.git] / dbck / dbck.dc
index f2405717c55d5d387532a547353c03fc9c44fd91..4c644ef336c8e55fab284337cd36d3987386a712 100644 (file)
@@ -12,7 +12,8 @@
 #include <strings.h>
 #include <signal.h>
 #include "dbck.h"
-
+EXEC SQL INCLUDE sqlca;
+EXEC SQL INCLUDE sqlda;
 
 static char dbck_qc_rcsid[] = "$Header$";
 
@@ -23,12 +24,13 @@ int fast = 0;
 int warn = 1;
 int abort_p = 0;
 struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys;
-struct hash *strings, *members;
+struct hash *strings, *members, *subnets, *string_dups;
 EXEC SQL BEGIN DECLARE SECTION; 
 int dcmenable;
 EXEC SQL END DECLARE SECTION; 
 struct save_queue *modtables, *sq_create();
-int interrupt();
+void interrupt();
+SQLDA *mr_sqlda;
 
 
 main(argc, argv)
@@ -43,6 +45,7 @@ EXEC SQL END DECLARE SECTION;
     int countonly = 0;
 
     database = "moira";
+    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
 
     while (++arg - argv < argc) {
        if  (**arg == '-')
@@ -92,17 +95,17 @@ EXEC SQL END DECLARE SECTION;
     if (debug)
       printf("Debug level is %d\n", debug);
 
-    setlinebuf(stdout);
-
     signal(SIGHUP, interrupt);
     signal(SIGQUIT, interrupt);
     signal(SIGINT, interrupt);
+
     modtables = sq_create();
+    mr_sqlda = sqlald(1, 255, 0);
 
-    IIseterr(ingerr);
+    EXEC SQL WHENEVER SQLERROR DO dbmserr();
     printf("Opening database %s...", database);
     fflush(stdout);
-    EXEC SQL CONNECT :database;
+    EXEC SQL CONNECT :database IDENTIFIED BY :database;
     printf("done\n");
     EXEC SQL SELECT value INTO :dcmenable FROM numvalues 
        WHERE name='dcm_enable'; 
@@ -123,7 +126,6 @@ EXEC SQL END DECLARE SECTION;
        EXEC SQL COMMIT WORK;
     }
     phase4();
-
     EXEC SQL COMMIT WORK;
 
     cleanup();
@@ -131,11 +133,18 @@ EXEC SQL END DECLARE SECTION;
     exit(0);
 }
 
-ingerr(num)
-int    *num;
+dbmserr()
 {
-    if (*num == 100) return;
-    printf("An ingres error occuurred, code %d\n", *num);
+EXEC SQL BEGIN DECLARE SECTION;
+    char buf[512];
+EXEC SQL END DECLARE SECTION;
+    int bufsize=256, msglength=0;
+
+    if (sqlca.sqlcode==1403) return;
+    printf("A DBMS error occurred, code %d\n", sqlca.sqlcode);
+    sqlglm(buf, &bufsize, &msglength);
+    buf[msglength]=0;
+    printf("%s\n", buf);
     printf("Aborting...\n");
     if (!abort_p) {
        abort_p++;
@@ -145,13 +154,10 @@ int       *num;
 }
 
 
-int interrupt()
+void interrupt()
 {
     printf("Signal caught\n");
     if (prompt("Save database changes")) {
-       /* break out of a retrieve loop */
-       IIbreak();
-
        EXEC SQL COMMIT WORK;
        cleanup();
        exit(0);
@@ -159,8 +165,6 @@ int interrupt()
     printf("Aborting transaction\n");
     if (!abort_p) {
        abort_p++;
-       /* break out of a retrieve loop */
-       IIbreak();
        EXEC SQL ROLLBACK WORK;
     }
 
@@ -184,7 +188,7 @@ cleanup()
     EXEC SQL END DECLARE SECTION; 
 
     while (sq_get_data(modtables, &tab)) {
-       EXEC SQL REPEATED UPDATE tblstats SET modtime='now'
+       EXEC SQL UPDATE tblstats SET modtime=SYSDATE
            WHERE table_name = :tab;
     }
     EXEC SQL UPDATE numvalues SET value = :dcmenable
@@ -197,15 +201,11 @@ char *msg;
 {
     fprintf(stderr, "Out of memory while %s\n", msg);
     if (prompt("Save database changes")) {
-       /* break out of a retrieve loop */
-       IIbreak();
-
        EXEC SQL COMMIT WORK;
        cleanup();
        exit(1);
     }
     printf("Aborting transaction\n");
-    IIbreak();
     EXEC SQL ROLLBACK WORK;
     exit(1);
 }
This page took 0.036038 seconds and 4 git commands to generate.