Hi Rainer,

I implementing application using SmartGWT, using FilterBuilder grid. See http://www.smartclient.com/smartgwt/showcase/#featured_filter_builder_grid Parsing result and trasform in query is more complicated if not exist Brackets "(".
Is possible implementing method "addBrackets" in DBColumnExpr?

Es.
   public DBCompareColExpr addBrackets(Object value)
   {
       return  .......
   }

Regards
Frank

Rainer Döbele ha scritto:
Hi Frank,

(almost) everything is possible but not always sensible.

First, an "OR" in a where clause is very rarely needed and should be avoided if 
possible. In your case e.g. it is much smarter to write:

  WHERE col1=val1 and col2 in (val2, val3)

In Empire-db you can write it like this:
  cmd.where(col1.is(val1).and((col2.in(new Object[] { val2, val3 })));

Or like this:
  cmd.where(col1.is(val1));
  cmd.where(col2.in(new Object[] { val2, val3 }));

I recommend the latter since it is much better understandable and you can 
easily enable or disable certain constraints.

But to answer your question for cases where it is not possible to avoid the 
"or":
The answer is that Empire-db sets parenthesis automatically depending on how 
you specify your constraints.

So if you want something like (col1=x and (col2=y or col3=z)) you'd write:
  cmd.where(col1.is(x));
  cmd.where(col2.is(y).or(col3.is(z));

Instead, if you want the condition to be ((col1=x and col2=y) or col3=z) you'd 
write:
  cmd.where(col1.is(x).and(col2.is(y)).or(col3.is(z));

In case of an "or" the parenthesis are automatically set from left to right.
Hope this has helped.

Regards
Rainer


Frank Lupo wrote:
re: Query

I have a query:

... WHERE col1=val1 and (col2=val2 or col2=val3)

In DBCommand is possible to specify the "(" ?

Thanks


 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
autenticato? GRATIS solo con Email.it http://www.email.it/f

 Sponsor:
 Diventa uno dei magnifici 8! Entra a fare parte della squadra Italiana di
Poker Sportivo con PokerClub
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8804&d=8-4
------------------------------------------------------------------------


Nessun virus nel messaggio in arrivo.
Controllato da AVG - www.avg.com Versione: 8.0.238 / Database dei virus: 270.11.47/2047 - Data di rilascio: 04/08/09 05:53:00





--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP 
autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Servizi Internet sul tuo cellulare con m.email, installalo gratuitamente e fai 
nuove scoperte
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8921&d=9-4

Reply via email to