X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql-classes.lisp;h=5983f7c9cecfc80fccc308be45ac1acc64284a7c;hb=7aadf2bbca30301d2479a21edbcdcb6e12da5cd0;hp=66e2cbbb2d47ed01efba94ce341f73c34dc932b1;hpb=041283a294efc5303c1632b57536e0823c9f8bee;p=umlisp.git diff --git a/sql-classes.lisp b/sql-classes.lisp index 66e2cbb..5983f7c 100644 --- a/sql-classes.lisp +++ b/sql-classes.lisp @@ -65,7 +65,7 @@ ,@(when %%order (list %%order)) (cond ((and ,%single ,%limit) - (error "Can't set single and limit")) + (error "Can't set single (~S) and limit (~S)" ,%single ,%limit)) (,%single " LIMIT 1") (,%limit @@ -598,17 +598,6 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS" :sui sui :saui saui :sdui sdui :scui scui :lat lat :str str))) -(defun find-ucxt-cuisui (cui sui &key (srl *current-srl*)) - (ensure-cui-integer cui) - (ensure-sui-integer sui) - (collect-umlisp-query (mrcxt (sab rank code cxn cxl cxs cui2 hcd rela xc) - srl kcuisui (make-cuisui cui sui) :lrl ksrl) - (make-instance 'ucxt :sab sab :code code - :rank rank - :cxn (ensure-integer cxn) :cxl cxl :cxs cxs :hcd hcd - :rela rela :xc xc - :cui2 (ensure-integer cui2)))) - (defun find-uhier-cui (cui &key (srl *current-srl*)) (ensure-cui-integer cui) (collect-umlisp-query (mrhier (aui cxn paui sab rela ptr hcd cvf) @@ -744,17 +733,17 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS" (let ((query (format nil "SELECT c.cui FROM MRCONSO c,MRXW_ENG x WHERE x.WD ~A '~A' AND x.cui=c.cui AND ~A ~A" (if like "LIKE" "=") (clsql-sys::sql-escape-quotes word) - (typecase sab + (etypecase sab (string - (format nil " c.sab='" (clsql-sys::sql-escape-quotes sab))) + (format nil " c.sab='~A'" (clsql-sys::sql-escape-quotes sab))) (cons - (format nil " c.sab IN (~('~A'~^,~))" + (format nil " c.sab IN (~{'~A'~^,~})" (mapcar 'clsql-sys::sql-escape-quotes sab))) - (t + (null (error "SAB missing"))) (if srl (format nil "AND KCUILRL <= ~A" srl) "")))) (loop for tuple in (mutex-sql-query query) - collect (make-instance 'ucon (first tuple))))) + collect (make-instance 'ucon :cui (first tuple))))) (defun find-ustr-word-sab (word &key sab (srl *current-srl*) (like nil)) "Return list of ustr that match word in matching SAB. Optionally, use SQL's LIKE syntax" @@ -1092,25 +1081,3 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS" (collect-umlisp-query (ustats (name count) nil srl srl :order (name asc)) (make-instance 'ustats :name name :hits (ensure-integer count)))) - - -(defun find-bsab-sab (sab) - (collect-umlisp-query (bonus_sab (name count) nil sab sab :single t) - (make-instance 'bsab :sab sab :name name :hits (ensure-integer count)))) - -(defun find-bsab-all () - (collect-umlisp-query (bonus_sab (sab name count) nil nil nil :order (sab asc)) - (make-instance 'bsab :sab sab :name name :hits (ensure-integer count)))) - -(defun find-btty-tty (tty) - (collect-umlisp-query (bonus_tty (name count) nil tty tty :single t) - (make-instance 'btty :tty tty :name name :hits (ensure-integer count)))) - -(defun find-btty-all () - (collect-umlisp-query (bonus_tty (tty name count) nil nil nil :order (tty asc)) - (make-instance 'btty :tty tty :name name :hits (ensure-integer count)))) - -(defun find-brel-rel (rel) - (collect-umlisp-query (bonus_rel (sab sl rel rela count) nil rel rel) - (make-instance 'brel :sab sab :sl sl :rel rel :rela rela - :hits (ensure-integer count))))