jill han wrote:

Below is a piece of code to get records from a table and exception
// startDate and endDate are Date object
// aDate has Date data type in oracle db
String sql = "Select * from aTable ";
sql = sql + " Where aDate ";
sql = sql + " Between '" + startDate + "' And '" + endDate + "' ";
List sqlResult = aTablePeer.executeQuery(sql);

org.apache.torque.TorqueException: ORA-01858: a non-numeric character
was found where a numeric was expected


Thanks in advance.

Jill


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



Using Criteria and calender can solve this problem.
This is sort of the type of code you would use:
GregorianCalendar calendar = new GregorianCalendar();
//  this  normalizies  the dates
calendar.setTime(startDate);
calendar.setTime(endDate);
Criteria sql = new Criteria();
sql.add(aDate, startDate, Criteria.GREATER_EQUAL);
Criteria.Criterion criterion = sql.getCriterion(aDate);
criterion.and(sql.getNewCriterion(criterion.getTable(), criterion.getColumn(), endDate, Criteria.LESS_EQUAL));
try
{
List list = aTablePeer.doSelect(sql);
}
catch(Exceptiion e)
{}


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

Reply via email to