Re: [Cppcms-users] Bizarre prepared statement problem
Brought to you by:
artyom-beilis
From: <ele...@ex...> - 2012-05-22 04:21:21
|
> Have you tried to change the type to datetime? Because > converting dates and numbers is not always well defined... Isn't SQLites datetime data type affinity to NUMERIC anyway? > > Also show the *full* code and full schema. > Ive slightly simplified the SQL query in my original email, but here is the whole function. cppdb::result Base::get_all_items(unsigned int aircraft_id, const Table& tbl, int date_limited_only) { cppdb::result r; //std::tm ts = dt_to_time(session_timestamp()); string ts = "2012-05-17 23:59:59"; ostringstream os; os << "SELECT i.id, i.name, i.remarks, i.part_number, h1.id AS rev_id, "; os << tbl.column_string("h1") << " "; os << "FROM " << tbl.name() << "s i "; os << "INNER JOIN " << tbl.name() << "s_history h1 ON h1.root_id=i.id "; os << "AND h1.days >= ? AND h1.date_fitted <= ? AND (h1.disabled_at IS NULL OR h1.disabled_at > ?) "; os << "AND h1.id IN (SELECT max(h2.id) FROM " << tbl.name() << "s_history h2 WHERE h2.date_fitted <= ? AND h2.root_id=i.id)"; os << "WHERE h1.aircraft_id = ? ORDER BY i.id ASC"; r = sql << os.str() << date_limited_only << ts << ts << ts << aircraft_id; return r; } |