[Qt-interest] QSqlQuery: Binding QStringLists

Ellen Kestrel dragonflykes at gmail.com
Tue Sep 20 09:20:12 CEST 2011


I would like to be able to turn a QStringList of arbitrary length (for
example: {"a", "b", "c", "d"}) into a properly escaped query along the lines
of "delete from TableName where value not in ("a", "b", "c", "d")".

My intuition would be to try this:
query.prepare ("delete from TableName where value not in :set");
query.bindValue (":set", stringList);

or maybe
query.prepare ("delete from TableName where value not in (:set)");

Does one of these work?  I see that bindValue is overloaded for QVariant,
which can indeed be a QStringList, but does the bind work as expected?  It
seems like outputting lastQuery () only shows the placeholders, and not the
actual bound values.

EK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110920/8b7429f5/attachment.html 


More information about the Qt-interest-old mailing list