PDA

View Full Version : Select statemen with bindvalues in Firebird 2 doesn't work



corrado1972
1st September 2010, 15:59
How can i prepare sql SELECT statement using bindvalues ?
Database is firebird 2.1. , QT 4.6

an example with named placeholders:

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

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