r10253: Automated commit for Debian build of clsql upstream-version-3.1.5
[clsql.git] / sql / operations.lisp
index ad785b35ffc28b36e41bf41a070b88333e0abe81..94ee20964b5c089ded361d10902eb30b890881c6 100644 (file)
@@ -66,7 +66,7 @@
 
 (defsql sql-minus (:symbol "minus") (&rest rest)
   (make-instance 'sql-set-exp 
-                :operator 'except :sub-expressions rest))
+                :operator 'minus :sub-expressions rest))
 
 (defsql sql-limit (:symbol "limit") (&rest rest)
   (make-instance 'sql-query-modifier-exp 
   (make-instance 'sql-relational-exp
                  :operator 'in :sub-expressions rest))
 
-(defsql sql-concat (:symbol "concat") (&rest rest)
+(defsql sql-concat-op (:symbol "concat-op") (&rest rest)
   (make-instance 'sql-relational-exp
                 :operator '\|\| :sub-expressions rest))
 
+(defsql sql-concat (:symbol "concat") (&rest rest)
+  (make-instance 'sql-function-exp
+                :name 'concat :args rest))
+
 (defsql sql-substr (:symbol "substr") (&rest rest)
   (if (= (length rest) 3)
       (make-instance 'sql-function-exp 
-                    :name 'substring :args rest)
+                    :name 'substr :args rest)
       (error 'sql-user-error :message "SUBSTR must have 3 arguments.")))
 
+(defsql sql-substring (:symbol "substring") (&rest rest)
+  (if (= (length rest) 3)
+      (make-instance 'sql-function-exp 
+                    :name 'substring :args rest)
+      (error 'sql-user-error :message "SUBSTRING must have 3 arguments.")))
+
 (defsql sql-is (:symbol "is") (&rest rest)
   (make-instance 'sql-relational-exp
                 :operator 'is :sub-expressions rest))
                 :name 'coalesce :args rest))
 
 (defsql sql-nvl (:symbol "nvl") (&rest rest)
-  (make-instance 'sql-function-exp
-                :name 'coalesce :args rest))
+  (if (= (length rest) 2)      
+      (make-instance 'sql-function-exp
+                     :name 'coalesce :args rest)
+      (error 'sql-user-error :message "NVL accepts exactly 2 arguments.")))
 
 (defsql sql-userenv (:symbol "userenv") (&rest rest)
   (make-instance 'sql-function-exp
                 :name 'userenv :args rest))
+
+(defsql sql-lower  (:symbol "lower") (&rest rest)
+  (if (= (length rest) 1)
+      (make-instance 'sql-function-exp
+                     :name 'lower :args rest)
+    (error 'sql-user-error :message "LOWER must have 1 argument.")))
+
+(defsql sql-upper  (:symbol "upper") (&rest rest)
+  (if (= (length rest) 1)
+      (make-instance 'sql-function-exp
+                     :name 'upper :args rest)
+    (error 'sql-user-error :message "UPPER must have 1 argument.")))