(sql (:insert-into 'kupci :set (:raw (if (/= (length (parameter "ime")) 0) (sql ('ime (parameter "ime")))))))
For this I get an error: Invalid amount of :set arguments passed to insert-into sql operator
Why is that ?
Thanks
I simplified the example:
(sql (:insert-into 'kupci :set (:raw (if t (sql ('ime "a"))))))
and still getting the same error message. Why I can't combine insert-into and :set with (:raw ...) ?
(sql (:insert-into 'kupci :set (:raw (if t (sql ('ime "a"))))))
The :insert-into clause expects the arguments to :set to be a multiple of two. You'll need to use sql-compile to do this.
(sql-compile `(:insert-into 'kupci :set ,@(when t (list 'ime "a"))))
How do I do it if I have multiple IFs like:
(sql-compile `(:insert-into 'kupci :set ,@((if TEST (list 'ime "a") (if TEST2 (list 'prezime "b")))))
or how ?
For every field in a database I want to test is even something entered and add that pair of field name and a value to the list. How do I do that ?
How do I do it if I have multiple IFs like:
(sql-compile `(:insert-into 'kupci :set ,@((if TEST (list 'ime "a") (if TEST2 (list 'prezime "b")))))
The first step would be understanding how quasiquoting works. This is not a Postmodern question, but a basic Common Lisp one. There are other channels for that.
postmodern-devel@common-lisp.net