""))
(%%lrl (format nil " AND ~:@(~A~)<=" lrl))
(%%where (when where-name
- (format nil " where ~:@(~A~)~A" where-name
+ (format nil " WHERE ~:@(~A~)~A" where-name
(if like " like " ""))))
(%filter (gensym "FILTER-"))
(%single (gensym "SINGLE-"))
(number
(concatenate 'string "='" (write-to-string ,where-value) "'"))
(null
- " is null")
+ " IS NULL")
(t
(format nil ,(if like "'%~A%'" "='~A'") ,where-value)))))
(if ,%filter (concatenate 'string
(when single (setq limit 1))
(concatenate
'string
- (format nil "select ~A~{~:@(~A~)~^,~} from ~:@(~A~)"
- (if distinct "distinct " "") fields table)
- (if where-name (format nil " where ~:@(~A~)" where-name) "")
+ (format nil "SELECT ~A~{~:@(~A~)~^,~} FROM ~:@(~A~)"
+ (if distinct "DISTINCT " "") fields table)
+ (if where-name (format nil " WHERE ~:@(~A~)" where-name) "")
(if where-name
(format nil
(typecase where-value
(number "='~D'")
- (null " is null")
+ (null " IS NULL")
(t
- (if like " like '%~A%""='~A'")))
+ (if like " LINK '%~A%""='~A'")))
where-value)
"")
(if filter (concatenate 'string " AND " filter) nil)
- (if srl (format nil " and ~:@(~A~)<=~D" lrl srl) "")
- (if order (format nil " order by ~{~:@(~A~) ~(~A~)~^,~}" order) "")
- (if limit (format nil " limit ~D" limit) "")))
+ (if srl (format nil " AND ~:@(~A~)<=~D" lrl srl) "")
+ (if order (format nil " ORDER BY ~{~:@(~A~) ~(~A~)~^,~}" order) "")
+ (if limit (format nil " LIMIT ~D" limit) "")))
(defmacro umlisp-query (table fields srl where-name where-value
(ensure-cui-integer cui)
(ensure-lui-integer lui)
(ensure-sui-integer sui)
- (let ((ls "select CODE,ATN,SAB,ATV from MRSAT where "))
+ (let ((ls "SELECT CODE,ATN,SAB,ATV FROM MRSAT WHERE "))
(cond
(sui (string-append ls "KCUISUI='"
(integer-string (make-cuisui cui sui) 14)