From: fireblade
Subject: Reverse CLSQL syntax
Date: 
Message-ID: <1176470427.219598.250540@o5g2000hsb.googlegroups.com>
I'm using CLSQL for my tech demonstrator .The bracketed syntax is very
unlispy
to me , maybe is question of taste but it's odd for me. The other
option  is
to use query and execute-command .In order to save me from
concatenating and
printing to string, and blank spaces i wrote a small function sql-txt
that lets me write
(let ((eventNo 11))
 (query
  (txt "select  *  from accounting_events"
           "where eventId =" eventNo)))
=>
(query  "select * from accounting_events where eventId = 11")

But that's doesn't look lispy enaphe , i want to be able to write
something like
(let ((eventNo 11))
  (query
    (lispy-txt
      select * from accounting_events
         where eventId = ,eventNo)))

And i have a comma outside of a backquote problem.
Any idea ?

bobi

From: Timofei Shatrov
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <461fa12a.28069882@news.readfreenews.net>
On 13 Apr 2007 06:20:27 -0700, "fireblade" <·················@gmail.com> tried
to confuse everyone with this message:

>I'm using CLSQL for my tech demonstrator.
...
>But that's doesn't look lispy enaphe , i want to be able to write
>something like
>(let ((eventNo 11))
>  (query
>    (lispy-txt
>      select * from accounting_events
>         where eventId = ,eventNo)))
>
>And i have a comma outside of a backquote problem.
>Any idea ?
>

Yes, make lispy-txt a function of one argument and write

(let ((eventNo 11))
  (query
    (lispy-txt
      `(select * from accounting_events
               where eventId = ,eventNo))))

Is SQL case-insensitive? If not, you'll also have to make some effort to
preserve the case of the symbols.

-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|
From: fireblade
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <1176802284.153540.243490@l77g2000hsb.googlegroups.com>
Seems i would have to learn to leave with brackets or write a rather
complex macro.
From: ·················@gmail.com
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <1176813696.530735.207490@d57g2000hsg.googlegroups.com>
I would kill for a mapcar in Delphi.

Pet
From: Lars Rune Nøstdal
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <461fb6ce$0$29070$c83e3ef6@nn1-read.tele2.net>
On Fri, 13 Apr 2007 06:20:27 -0700, fireblade wrote:

> I'm using CLSQL for my tech demonstrator. The bracketed syntax is very
> unlispy to me, maybe is question of taste but it's odd for me. 

I found this somewhere:

;; For CLSQL SQL-syntax.
(modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table)
(modify-syntax-entry ?\] ")[" lisp-mode-syntax-table)

..(put it in ~/.emacs) .. it helps with indentation and highlights 
matching [ and ] pairs.

But yes, I miss Lispy syntax also. I find the syntax in Postmodern 
( http://common-lisp.net/project/postmodern/ ) more comfortable. But 
CLSQL is probably more mature then Postmodern in some ways - I'm not 
sure. 

-- 
Lars Rune Nøstdal
http://nostdal.org/
From: Thomas A. Russ
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <ymihcrg18y6.fsf@sevak.isi.edu>
"fireblade" <·················@gmail.com> writes:

> I'm using CLSQL for my tech demonstrator .The bracketed syntax is very
> unlispy
> to me , maybe is question of taste but it's odd for me. The other
> option  is
> to use query and execute-command .In order to save me from
> concatenating and
> printing to string, and blank spaces i wrote a small function sql-txt
> that lets me write
> (let ((eventNo 11))
>  (query
>   (txt "select  *  from accounting_events"
>            "where eventId =" eventNo)))
> =>
> (query  "select * from accounting_events where eventId = 11")

Well, there's always using (FORMAT NIL ...) but that may not be Lispy
enough for you either, even though format is built in.  You would then
write something like:

  (format nil "select * from accounting_events where eventId = ~D"
        eventNo)

to get the string you want.

> But that's doesn't look lispy enaphe , i want to be able to write
> something like
> (let ((eventNo 11))
>   (query
>     (lispy-txt
>       select * from accounting_events
>          where eventId = ,eventNo)))
> 
> And i have a comma outside of a backquote problem.
> Any idea ?

The problem is that you can't really build what you want at the lisp
level, because you want to have the characters interpreted differently.
But things like the comma and the case of the symbols is handled at read
time.  So your only option is to implement some type of specialized
reader macro to do this.  Of course, when you do this, you would be well
advised to use a character other than comma to indicate insertion, since
commas are legal SQL characters, especially if you want to select only a
few fields instead of all of them.

My suggestion is to just come to terms with the bracket notation, or
else to go to some type of FORMAT-based solution.  The syntax may not be
lispy enough, but you have to accept that you are writing SQL and not
lisp, so it shouldn't be surprising that it looks different.

Your other option is to find a lisp-based SQL generator.  I suppose that
one design (or maybe even find) something that would look like:

 (:select :* :from '|accounting_events| :WHERE '|eventID| := eventNo)

or something like that.  I'm not sure it would really be an improvement,
though.



-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Alan Manuel K. Gloria
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <1176777235.339812.259970@w1g2000hsg.googlegroups.com>
On Apr 17, 2:16 am, ····@sevak.isi.edu (Thomas A. Russ) wrote:
> "fireblade" <·················@gmail.com> writes:
> > I'm using CLSQL for my tech demonstrator .The bracketed syntax is very
> > unlispy
> > to me , maybe is question of taste but it's odd for me. The other
> > option  is
> > to use query and execute-command .In order to save me from
> > concatenating and
> > printing to string, and blank spaces i wrote a small function sql-txt
> > that lets me write
> > (let ((eventNo 11))
> >  (query
> >   (txt "select  *  from accounting_events"
> >            "where eventId =" eventNo)))
> > =>
> > (query  "select * from accounting_events where eventId = 11")
>
> Well, there's always using (FORMAT NIL ...) but that may not be Lispy
> enough for you either, even though format is built in.  You would then
> write something like:
>
>   (format nil "select * from accounting_events where eventId = ~D"
>         eventNo)
>
> to get the string you want.
>
> > But that's doesn't look lispy enaphe , i want to be able to write
> > something like
> > (let ((eventNo 11))
> >   (query
> >     (lispy-txt
> >       select * from accounting_events
> >          where eventId = ,eventNo)))
>
> > And i have a comma outside of a backquote problem.
> > Any idea ?
>
> The problem is that you can't really build what you want at the lisp
> level, because you want to have the characters interpreted differently.
> But things like the comma and the case of the symbols is handled at read
> time.  So your only option is to implement some type of specialized
> reader macro to do this.  Of course, when you do this, you would be well
> advised to use a character other than comma to indicate insertion, since
> commas are legal SQL characters, especially if you want to select only a
> few fields instead of all of them.
>
> My suggestion is to just come to terms with the bracket notation, or
> else to go to some type of FORMAT-based solution.  The syntax may not be
> lispy enough, but you have to accept that you are writing SQL and not
> lisp, so it shouldn't be surprising that it looks different.
>
> Your other option is to find a lisp-based SQL generator.  I suppose that
> one design (or maybe even find) something that would look like:
>
>  (:select :* :from '|accounting_events| :WHERE '|eventID| := eventNo)
>
> or something like that.  I'm not sure it would really be an improvement,
> though.
>
Hey, wait a minute - can't "loop" be used as a model?

So you can do something like:
(select *
     from accounting_events
     where event_id = eventNo)

Of course, select would now be an exceedingly complex macro, of about
the same complexity as loop.

And note, I have just about the barest knowledge of SQL.  It might be
much more complicated than that...
From: Ken Tilton
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <fnZUh.130$Ld4.18@newsfe12.lga>
Alan Manuel K. Gloria wrote:
> So you can do something like:
> (select *
>      from accounting_events
>      where event_id = eventNo)
> 
> Of course, select would now be an exceedingly complex macro, of about
> the same complexity as loop.
> 
> And note, I have just about the barest knowledge of SQL.  It might be
> much more complicated than that...
> 

Never apologize in advance for /potential/ stupidity and, when convinced 
of it, make excuses. That anyway is my policy, and a disappointingly 
large percentage of c.l.l still take me seriously.

hth,kzo

-- 
http://www.theoryyalgebra.com/

"Algebra is the metaphysics of arithmetic." - John Ray

"As long as algebra is taught in school,
there will be prayer in school." - Cokie Roberts

"Stand firm in your refusal to remain conscious during algebra."
    - Fran Lebowitz

"I'm an algebra liar. I figure two good lies make a positive."
    - Tim Allen
From: Petter Gustad
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <7dodln1o8d.fsf@www.gratismegler.no>
"Alan Manuel K. Gloria" <········@gmail.com> writes:

> Hey, wait a minute - can't "loop" be used as a model?

loop is some sort of a query language.

There is also a loop extension in clsql for iterating over a query
result:

 (loop for (e) being the records in [select ...see my previous message...]
            do (whatever))
  
Petter
-- 
A: Because it messes up 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: Petter Gustad
Subject: Re: Reverse CLSQL syntax
Date: 
Message-ID: <7dslaz1odf.fsf@www.gratismegler.no>
···@sevak.isi.edu (Thomas A. Russ) writes:

> Your other option is to find a lisp-based SQL generator.  I suppose that
> one design (or maybe even find) something that would look like:
> 
>  (:select :* :from '|accounting_events| :WHERE '|eventID| := eventNo)

In clsql:

[select * :from [accouting_event] :where [= [eventid] eventno]]

See:

http://clsql.b9.com/manual/sql.html

Petter

-- 
A: Because it messes up 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?