From: Jens Teich
Subject: [CLSQL] sql expressions inside loop invisible
Date: 
Message-ID: <umyxopequ.fsf@jensteich.de>
;; already posted on CLSQL-Help

(defun finde-pmw (lang &key bereich gruppe reihe produkt merkmal-array wert-array)
  (clsql:select 'projekt-merkmale-werte :flatp t
                :where
                [and [= [lang_id]      lang]
                     (if bereich    [= [guid_bereich] bereich   ] t)
                     (if gruppe     [= [guid_gruppe ] gruppe    ] t)
                     (if reihe      [= [guid_reihe  ] reihe     ] t)
                     (if produkt    [= [guid_produkt] produkt   ] t)
                     (if merkmal-array
                       (loop for i
                             for m across merkmal-array
                             do
                             [= [(format nil "merkmal~a" i)] m])
                       t)
                     (if wert-array
                       (loop for i
                             for w across wert-array
                             do
                             [= [(format nil "wert~a" i)] w])
                        t)]))

The two loop statements in this function do not work, their result is
'NULL'.

How do I get their contents made visible to the select?

Jens
-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

From: Matthias Benkard
Subject: Re: sql expressions inside loop invisible
Date: 
Message-ID: <1185123980.278162.26940@m3g2000hsh.googlegroups.com>
Hi,

> The two loop statements in this function do not work, their result is
> 'NULL'.

I'm just guessing wildly, but maybe you're looking for one of ALWAYS,
THEREIS or COLLECT rather than DO?  Like this:

CL-USER> (loop for x in '(1 3 4 5 7)
               thereis (evenp x))
T
CL-USER> (loop for x in '(1 3 4 5 7)
               always (evenp x))
NIL
CL-USER> (loop for x in '(1 3 4 5 7)
               collect (evenp x))
(NIL NIL T NIL NIL)

Note that I'm not at all familiar with CLSQL, so I might be way off.

You ought to provide a bit more information here.  �Doesn't work� is
usually not the right way to explain a problem.  (Oh, and having your
variable names in German is not quite the most helpful thing,
either. :))

Bye-bye,
Matthias
From: Jens Teich
Subject: Re: sql expressions inside loop invisible
Date: 
Message-ID: <ufy3gpc5m.fsf@jensteich.de>
Matthias Benkard <··········@gmail.com> writes:

> Hi,
>
>> The two loop statements in this function do not work, their result is
>> 'NULL'.
>
> I'm just guessing wildly, but maybe you're looking for one of ALWAYS,
> THEREIS or COLLECT rather than DO?  Like this:
>
> CL-USER> (loop for x in '(1 3 4 5 7)
>                thereis (evenp x))
> T
> CL-USER> (loop for x in '(1 3 4 5 7)
>                always (evenp x))
> NIL
> CL-USER> (loop for x in '(1 3 4 5 7)
>                collect (evenp x))
> (NIL NIL T NIL NIL)
>
> Note that I'm not at all familiar with CLSQL, so I might be way off.

There is a reader syntax in CLSQL like this

| > [= [test] 7]
| => #<CLSQL-SYS:SQL-RELATIONAL-EXP (test = 7)>

I basicly want to do something like

| > (loop for sql across #("test-1" "test-2") do [= [sql] sql])
| => NIL

resp

| > [and (loop for sql across #("test-1" "test-2") do [= [sql] sql])]
| => #<CLSQL-SYS:SQL-RELATIONAL-EXP (NULL)>

Trying your suggestion using keyword collect I get

| > [and (loop for sql across #("test-1" "test-2") collect [= [sql] sql])]
| => #<CLSQL-SYS:SQL-RELATIONAL-EXP ((sql = 'test-1') and (sql = 'test-2'))>

This is exactly what I want. CLSQL is more clever than I thought.

Thanks
Jens