r9507: rrf updates
[umlisp.git] / create-sql.lisp
index 6e50a0fe6f4bbd7cb359f6c3dbb32b152c5911a8..4978843e5bb280230387844eab008ee9544f5f6d 100644 (file)
   (let ((col-func 
         (lambda (c) 
           (let ((sqltype (sqltype c)))
+            (case *umls-sql-type*
+              (:oracle
+               (cond
+                ((string-equal sqltype "VARCHAR")
+                 (setq sqltype "VARCHAR2"))
+                ((string-equal sqltype "BIGINT")
+                 (setq sqltype "VARCHAR2(20)")))))
+            
             (concatenate 'string
-                         (col c)
-                         " "
-                         (if (or (string-equal sqltype "VARCHAR")
-                                 (string-equal sqltype "CHAR"))
-                             (format nil "~a (~a)" sqltype (cmax c))
-                             sqltype))))))
+              (col c)
+              " "
+              (if (or (string-equal sqltype "VARCHAR")
+                      (string-equal sqltype "CHAR"))
+                  (format nil "~a (~a)" sqltype (cmax c))
+                sqltype))))))
     (format nil "CREATE TABLE ~a (~{~a~^,~})" (table file)
            (mapcar col-func (ucols file)))))
 
 (defun noneng-lang-index-files ()
   (remove-if-not
    (lambda (f) (and (> (length (fil f)) 4)
-                   (string-equal (fil f) "MRXW." :end1 5) 
-                   (not (string-equal (fil f) "MRXW.ENG"))
-                   (not (string-equal (fil f) "MRXW.NONENG"))))
+                   (string-equal (fil f) "MRXW_" :end1 5) 
+                   (not (string-equal (fil f) "MRXW_ENG.RRF"))
+                   (not (string-equal (fil f) "MRXW_NONENG.RRF"))))
    *umls-files*))
 
 ;;; SQL Command Functions
@@ -221,7 +229,7 @@ This is much faster that using create-umls-db-insert."
 (defun translate-all-files (&optional (extension ".trans"))
   "Copy translated files and return postgresql copy commands to import"
   (make-noneng-index-file extension)
-  (dolist (f (remove "MRXW.NONENG" *umls-files* :test #'string= :key #'fil))
+  (dolist (f (remove "MRXW_NONENG.RRF" *umls-files* :test #'string= :key #'fil))
     (translate-umls-file f extension)))
 
 (defun translate-umls-file (file extension)
@@ -230,17 +238,17 @@ This is much faster that using create-umls-db-insert."
 
 (defun make-noneng-index-file (extension)
   "Make non-english index file"
-  (translate-files (find-ufile "MRXW.NONENG")
+  (translate-files (find-ufile "MRXW_NONENG.RRF")
                   extension (noneng-lang-index-files)))
 
 (defun translate-files (out-ufile extension input-ufiles)
   "Translate a umls file into a format suitable for sql copy cmd"
-  (let ((output-path (umls-pathname (fil out-ufile) extension)))
+  (let ((output-path (ufile-pathname out-ufile extension)))
     (if (probe-file output-path)
        (format t "File ~A already exists: skipping~%" output-path)
       (with-open-file (ostream output-path :direction :output)
        (dolist (input-ufile input-ufiles)
-         (with-umls-file (line (fil input-ufile))
+         (with-umls-ufile (line input-ufile)
            (translate-line out-ufile line ostream)
            (princ #\newline ostream)))))))