Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

SQLQuery works on SQLite browser but not Qt5.11.2



  • QString const command = QStringLiteral("with ab as ("
                                                   "select a.* from %1 a union all "
                                                   "select b.* from %2 b "
                                                   ")"
                                                   "SELECT ID, FaceID, Image "
                                                   "FROM (SELECT ab.*,"
                                                   "ROW_NUMBER() OVER (PARTITION BY FaceID ORDER BY DATE DESC, TIME DESC) "
                                                   "as seqnum FROM ab) ab "
                                                   "WHERE seqnum = 1 "
                                                   "ORDER BY Date DESC, Time DESC "
                                                   "LIMIT 5").
                    arg(get_table_name(table_name::recorded_face_whitelist_log),
                        get_table_name(table_name::recorded_face_log));        
           //do not call prepare since this print better error message
            query.exec(command);
    
            if(!query.lastError().isValid()){
                update_latest_face_impl(query);
            }else{
                QLOG_DEBUG()<<__func__<<query.lastError()<<"\ncommand:"<<command;
            }
    

    Error messages:

    QSqlError("1", "Unable to execute statement", "near "(": syntax error")

    This command works for the sqlite browser, not sure why it fail with Qt5.11.2

    Edit : I copy the command print by the QLOG_DEBUG to the sqlite browser, it works. The command do not has any special characters, so I should not need any "", weird.



  • Find out the reason, sqlite version of Qt.511.2 is too old


Log in to reply