"Haris" <fbogdano
...@xnet.hr> writes:
> How to repeat this piece of code with a macro:
> ,@(if (/= (length (parameter "ime")) 0) (list 'ime (parameter "ime"))
> (list 'ime :null))
Hard to say, since this is NOT a piece of code.
,@ outside of ` is meaningless.
> while 'ime and "ime" changes while repeating.
> That's already a part of a "sql-compile" macro, like this:
> (sql-compile `(:insert-into 'kupci :set
> ,@(if (/= (length (parameter "ime")) 0) (list 'ime (parameter "ime"))
> (list 'ime :null))
> ,@(if (/= (length (parameter "prezime")) 0) (list 'prezime (parameter
> "prezime")) (list 'prezime
> and so on.
> I should be able to call it like: (a-macro 'ime 'prezime ...)
I can't see any reason why it should be a macro.
(defun generate-sql-set (parameter)
(let* ((name (string parameter))
(value (parameter name)))
(list parameter
(if (zerop (length value))
:null
value))))
(defun generate-sql-sets (parameters)
(reduce (function append) parameters
:key (function generate-sql-set)
:from-end t))
(sql-compile `(:insert-into 'kupci :set ,(generate-sql-sets '(ime prezime))))
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.