> Hi folks,
 >
 > i've got the following SQL:
 >
 > select * from employee
 > where
 > valid_from is null and valid_to is null or
 > valid_from is null and '2005-02-14' < valid_to  or
 > valid_from <= '2005-02-14' and valid_to is null or
 > valid_from <= '2005-02-14' and '2005-02-14'  < valid_to
 >
 > I need to build this query with torque.
 > EmployeePeer.doSelect(c);
 >
 > I have no idea how the criteria() would look like. I have problems to
 > put all the and's and or's together. Nothing i do gives the above query.
 > Who can help?
 >
 > Michael
 > --
 
 You can do the following, supposing that you used torque to generate your
 base classes:
 
 Criteria c = new Criteria();
 c.add(BaseClassPeer.FIELD,(Object) (" valid_from is null and valid_to is
 null  or valid_from is null and '2005-02-14' < valid_to  or valid_from <=
 '2005-02-14' and valid_to is null or valid_from <= '2005-02-14' and
 '2005-02-14'  < valid_to "),Criteria.CUSTOM);
 Vector v = BaseClassPeer.doSelect(crit);
 return v;
 
 If you want to have a look at the query, you can do the following:
 c.toString();

Good luck!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to