I have a tablename as string, a list of fieldnames as strings and a list of values known only at runtime all.
Tried the following. What is going wrong?
HB> (sql (append (list :insert-into (intern "table") :set) (loop for k in '("field1" "field2" "field3") for v in '(4 5 6) append (list (intern k) v))))
Error: Value (:INSERT-INTO |table| :SET |field1| 4 |field2| 5 |field3| 6) can not be converted to an SQL literal. [Condition of type SIMPLE-ERROR]
Jens
Hi Jens,
The expansion of SQL forms happens at macroexpansion time, while you are building your query expression at run-time. Using SQL-COMPILE where you now have SQL solves the problem.
Cheers, Marijn
On Mon, Apr 14, 2008 at 2:59 PM, Jens Teich info@jensteich.de wrote:
I have a tablename as string, a list of fieldnames as strings and a list of values known only at runtime all.
Tried the following. What is going wrong?
HB> (sql (append (list :insert-into (intern "table") :set) (loop for k in '("field1" "field2" "field3") for v in '(4 5 6) append (list (intern k) v))))
Error: Value (:INSERT-INTO |table| :SET |field1| 4 |field2| 5 |field3| 6) can not be converted to an SQL literal. [Condition of type SIMPLE-ERROR]
Jens _______________________________________________ postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
Hi Marijn,
works like a charm.
Thanks for your great postmodern library.
Jens
Am 14.04.2008 um 15:05 schrieb Marijn Haverbeke:
Hi Jens,
The expansion of SQL forms happens at macroexpansion time, while you are building your query expression at run-time. Using SQL-COMPILE where you now have SQL solves the problem.
Cheers, Marijn
On Mon, Apr 14, 2008 at 2:59 PM, Jens Teich info@jensteich.de wrote:
I have a tablename as string, a list of fieldnames as strings and a list of values known only at runtime all.
Tried the following. What is going wrong?
HB> (sql (append (list :insert-into (intern "table") :set) (loop for k in '("field1" "field2" "field3") for v in '(4 5 6) append (list (intern k) v))))
Error: Value (:INSERT-INTO |table| :SET |field1| 4 |field2| 5 | field3| 6) can not be converted to an SQL literal. [Condition of type SIMPLE-ERROR]
Jens _______________________________________________ postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
postmodern-devel@common-lisp.net