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
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) |______________|
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/
"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
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...
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
"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?
···@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?