[PyQt] QSqlQuery: one parameter in two different places?

Sibylle Koczian Sibylle.Koczian at t-online.de
Tue Jan 1 21:15:22 GMT 2008


Hello, 

my SQL query has this form:

sqltext = 'UPDATE mytable SET field_1 = :newvalue WHERE field_2 < :newvalue'

The database is SQLITE. If I use this query as is:

query = QSqlQuery()
query.prepare(sqltext)
query.bindValue(':newvalue', QVariant(mynewvalue))
query.exec()

then nothing is updated. If I change to

sqltext = 'UPDATE mytable SET field_1 = :value_1 WHERE field_2 < :value_2'
query = QSqlQuery()
query.prepare(sqltext)
query.bindValue(':value_1', QVariant(mynewvalue))
query.bindValue(':value_2', QVariant(mynewvalue))
query.exec()

the update works as expected. Can't I use the same parameter name in two 
different places of the query, if I want to use the same value twice?

Thank you,
Sibylle

-- 
Dr. Sibylle Koczian


More information about the PyQt mailing list