;;;; Author: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: sql-classes.lisp,v 1.61 2003/05/04 01:18:10 kevin Exp $
+;;;; $Id: sql-classes.lisp,v 1.64 2003/05/04 01:34:33 kevin Exp $
;;;;
;;;; This file, part of UMLisp, is
;;;; Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
,@body)))))))
-
(defmacro umlisp-query (table fields srl where-name where-value
&key (lrl "KCUILRL") single distinct order like)
"Query the UMLisp database. Return a list of umlisp objects whose name
,%%fields
,@(when %%where (list %%where))
,@(when %%where
+ #+ignore
`((if (numberp ,where-value)
(write-to-string ,where-value)
- (format nil ,(if like "'%~A%'" "'~A'") ,where-value))))
+ (format nil ,(if like "'%~A%'" "'~A'") ,where-value)))
+ `((typecase ,where-value
+ (number
+ (write-to-string ,where-value))
+ ((nil)
+ " is null")
+ (t
+ (format nil ,(if like "'%~A%'" "'~A'") ,where-value)))))
(if ,srl (concatenate 'string ,%%lrl (write-to-string ,srl)) "")
,@(when %%order (list %%order))
,@(when single (list " limit 1")))))
(defun find-ucon-word (word &key (srl *current-srl*) (like nil))
"Return list of ucons that match word. Optionally, use SQL's LIKE syntax"
(with-umlisp-query-eval ('mrxw_eng '(cui) srl 'wd word :like like :distinct t
- :lrl klrl :order '(cui asc))
+ :lrl 'klrl :order '(cui asc))
(find-ucon-cui cui :srl srl)))
(defun find-ucon-normalized-word (word &key (srl *current-srl*) (like nil))
"Return list of ucons that match word, optionally use SQL's LIKE syntax"
(with-umlisp-query-eval ('mrxnw_eng '(cui) srl 'nwd word :like like :distinct t
- :lrl klrl :order '(cui asc))
+ :lrl 'klrl :order '(cui asc))
(find-ucon-cui cui :srl srl)))
(defun find-ustr-word (word &key (srl *current-srl*))