[postmodern-devel] Query generation
Osei Poku
opoku at ece.cmu.edu
Wed Jun 27 19:50:40 UTC 2007
On Wed, Jun 27, 2007 at 09:24:44PM +0200, Ralf Mattes wrote:
> On Wed, 2007-06-27 at 21:22 +0200, Ralf Mattes wrote:
> > On Wed, 2007-06-27 at 14:29 -0400, Osei Poku wrote:
> > > Hi,
> > >
> > > I want to generate the following query:
> > >
> > > "UPDATE table1 SET col1 = NULL, col2 = NULL"
> > >
> > > from the following list: ("col1" "col2")
> > >
> > > my attempt is:
> > >
> > > (sql
> > > (append
> > > '(:update :table1 :set)
> > > (loop for a in '("col1" "col2")
> > > collect a collect :NULL)))
> > >
> > > but that apparently doesnt work. this can probably be attributed to
> > > my newness to lisp.
> > >
> > > Any ideas?
> >
> > 'postmodern:sql' is a macro, not a function and hence will not evaluate
> > its argument. When your code really looks like above you could fix it
> > like this:
> >
> > (sql #.(append
> > '(:update :table1 :set)
> > (loop for a in '("col1" "col2")
> > collect a collect :NULL)))
> >
>
Aah, the beauty of the obscure and powerful reader macro :) This is
pretty much what I thought I needed until ...
>
> Sorry for following up my own post: if you really need to build up your
> SQL at runtime you could also use the functional pendant to 'sql':
>
> (sql-compile(append
> '(:update :table1 :set)
> (loop for a in '("col1" "col2")
> collect a collect :NULL)))
>
>
Yes. This is what I really want: the ability to freely insert
arbitrary s-exps in the s-sql syntax. The two solutions are probably
equivalent anyway.
Thanks a bunch.
> Cheers, RalfD
>
> >
> >
> >
> > > thanks
> > >
> >
> > _______________________________________________
> > postmodern-devel mailing list
> > postmodern-devel at common-lisp.net
> > http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>
> _______________________________________________
> postmodern-devel mailing list
> postmodern-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
--
Osei Poku
PhD Student, ECE
Carnegie Mellon University
More information about the postmodern-devel
mailing list