X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql-classes.lisp;h=f6f306ecb204ce8162f92bcf39b9dad8d01a5d3c;hb=357dad37300c0f2cc45156dae18bd89265c20431;hp=594103fcd95c0d9a7b3303f5119b1f3512854136;hpb=67ee261d341603e293f6b0314d5cd12522fa04c6;p=umlisp.git diff --git a/sql-classes.lisp b/sql-classes.lisp index 594103f..f6f306e 100644 --- a/sql-classes.lisp +++ b/sql-classes.lisp @@ -35,7 +35,7 @@ "")) (%%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-")) @@ -55,7 +55,7 @@ (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 @@ -78,22 +78,22 @@ (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 @@ -604,7 +604,7 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS" (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)