QSqlQuery query; query.prepare("SELECT * FROM employees"); query.exec(); // Process the results... query.clear(); // Clears the query for reuse.
QSqlQuery query; query.prepare("DELETE FROM employees WHERE salary < ?"); query.addBindValue(10000); query.exec(); query.clear(); // Clears the query for reuse.This example demonstrates the use of the clear function after executing a DELETE statement with a parameterized query. We bind a value to the placeholder in the query using the addBindValue function before executing it. After executing the query, we clear it for reuse. Package Library: The QSqlQuery class is part of the Qt SQL module, which is included in the Qt library. The Qt library is a cross-platform application and UI framework provided by The Qt Company.