(setq sqltype "VARCHAR2(20)")))))
(concatenate 'string
- (col c)
+ (sqlname c)
" "
(if (or (string-equal sqltype "VARCHAR")
(string-equal sqltype "CHAR"))
(delete-file output-path)
nil)
((eql input-lines translated-lines)
- (format t "Translated file ~A already exists: skipping...~%" output-path)
+ (format t "Translated file ~A exists and is proper number of lines: skipping...~%" output-path)
t)
((eql input-lines 0)
(warn "The number of input lines is 0 for output file ~A." output-path)
(defun set-current-srl (srl)
(setq *current-srl* srl))
+;; SQLNAME is required for collision of SQL reserved words (MYSQL 8: RANK)
+;; and column names in UMLS (RANK in MRRANK)
+(defvar *sql-reserved-names* '("RANK"))
+(defmethod sqlname ((c ucol))
+ (sqlname (col c)))
+(defmethod sqlname ((name string))
+ (if (find name *sql-reserved-names* :test #'string-equal)
+ (concatenate 'string "_" name)
+ name))
+(defmethod sqlname ((l list))
+ (mapcar #'sqlname l))
+(defmethod sqlname ((s symbol))
+ (sqlname (symbol-name s)))
+
(defmacro query-string (table fields srl where-name where-value
&key (lrl "KCUILRL") single distinct order like limit
filter)
(let* ((%%fields (format nil "SELECT ~A~{~:@(~A~)~^,~} FROM ~:@(~A~)"
- (if distinct "DISTINCT " "") fields table))
+ (if distinct "DISTINCT " "") (sqlname fields) table))
(%%order (if order (format nil " ORDER BY ~{~:@(~A~) ~(~A~)~^,~}"
order)
""))
(%%lrl (format nil " AND ~:@(~A~)<=" lrl))
(%%where (when where-name
- (format nil " WHERE ~:@(~A~)~A" where-name
+ (format nil " WHERE ~:@(~A~)~A" (sqlname where-name)
(if like " like " ""))))
(%filter (gensym "FILTER-"))
(%single (gensym "SINGLE-"))
(concatenate
'string
(format nil "SELECT ~A~{~:@(~A~)~^,~} FROM ~:@(~A~)"
- (if distinct "DISTINCT " "") fields table)
- (if where-name (format nil " WHERE ~:@(~A~)" where-name) "")
+ (if distinct "DISTINCT " "") (sqlname fields) table)
+ (if where-name (format nil " WHERE ~:@(~A~)" (sqlname where-name)) "")
(if where-name
(format nil
(typecase where-value
(defun find-ustats-srl (srl)
(collect-umlisp-query (ustats (name count) nil srl srl :order (name asc))
(make-instance 'ustats :name name :hits (ensure-integer count))))
+
+(defun find-urank-sab (sab &key (srl *current-srl*))
+ (collect-umlisp-query (mrrank (rank sab suppress tty) nil sab sab)
+ (make-instance 'urank :rank rank :sab sab :tty tty :suppress suppress)))
+
+(defun find-urank-all (&key (srl *current-srl*))
+ (if srl
+ (collect-umlisp-query (mrrank (rank sab suppress tty) nil ksrl srl)
+ (make-instance 'urank :rank rank :sab sab :tty tty :suppress suppress))
+ (collect-umlisp-query (mrrank (rank sab suppress tty ksrl) nil nil nil)
+ (make-instance 'urank :rank rank :sab sab :tty tty :suppress suppress))))