How can i prepare sql SELECT statement using bindvalues ?
Database is firebird 2.1. , QT 4.6
an example with named placeholders:
sql.append("SELECT * FROM NEW_TABLE WHERE DATEBIRTH = :date_param AND NAME = :name_param");
query.
bindValue(":date_param",
QDateTime::currentDateTime());
query.
bindValue(":name_param",
QString("SMITH"));
if (!query.prepare(sql))
// ERROR: Dynamic SQL Error - SQL error code = -206 - Column unknown - DATE_PARAM - At line 1, column 44 Could not prepare statement
QString sql;
sql.append("SELECT * FROM NEW_TABLE WHERE DATEBIRTH = :date_param AND NAME = :name_param");
QSqlQuery query(DB);
query.bindValue(":date_param",QDateTime::currentDateTime());
query.bindValue(":name_param",QString("SMITH"));
if (!query.prepare(sql))
// ERROR: Dynamic SQL Error - SQL error code = -206 - Column unknown - DATE_PARAM - At line 1, column 44 Could not prepare statement
To copy to clipboard, switch view to plain text mode
It does not work.
I wonder: why bind values doesn't works with SELECT statemen?
Is it a trouble of IBASE driver?
I think that the driver should known its data types and substitute them with the appropriate type conversion into sql prepared statement: why it force me to rewrite the query statement like: QString(" WHERE DATE = '10/10/1980' and name = 'SMITH' ") ?
thanks
Bookmarks