[erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang

Yariv Sadan <>
Tue Sep 19 19:34:54 CEST 2006


> That said, I think it's a good start and it opens interesting possibilities.

You are right :)

I added Lisp-style operator expansion to ErlSQL to simplify writing a
sequence of clauses with the same operator.

Here are a few examples

{select,'*',{from,foo},
    {where,{a,'=',{'+',[1,2,3]}}}} ->
"SELECT * FROM foo WHERE (a = 1 + 2 + 3)"

{select,'*',{from,foo}
    {where,{'=',[{'+',[a,b,c]},{'+',[d,e,f]}]}}} ->
"SELECT * FROM foo WHERE a + b + c = d + e + f"

{select,'*',{from,foo},
   {where,
     {'and',[{a,'=',b},{c,'=',d},{e,'=',f}]}}} ->
"SELECT * FROM foo WHERE (a = b) AND (c = d) AND (e = f)"

More information is here:

http://yarivsblog.com/articles/2006/09/19/new-erlsql-feature-lisp-style-operator-expansion

Cheers,
Yariv



More information about the erlang-questions mailing list