[Qt-interest] QSqlQuery and placeholders of the same name

Anthony Serdyukov uksus70 at gmail.com
Tue Dec 30 17:56:24 CET 2008


Thanks, but it's not an option. Specified query is just a sample. My
real query is very complicated. It has several subqueries, and the
placeholders of the same name are met at different places. So, query
cannot be reduced this way.

2008/12/30, Thiago Macieira <thiago.macieira at trolltech.com>:
> Bill KING wrote:
>>It was correctly rejected, as in the sqlite case, placeholders are
>>handled by the database engine itself and not qt, in this case, sqlite
>>has failed to bind correctly, even tho we've told it to. In the case of
>>database engines that don't support parameterised queries, then, we do
>>substituion ourselves to fill out the query. Honestly, if you're trying
>>to "be smart" by re-using the binding, don't, there's too many layers
>>that it can go wrong in, and saving one line of code is really not worth
>>it in the long run when you factor in testing, debugging, and rewriting
>>the code in the end anyway to do both bindings.
>
> Hint, rewrite your query like:
> 	select * from some_table where columnA = :param AND
> columnB = columnA
>
> Then there's only one parameter to be replaced and the meaning is still
> the same.
> --
> Thiago Macieira - thiago.macieira (AT) nokia.com
>   Senior Software Engineer - Nokia, Qt Software
>   Qt Software is hiring - ask me
>       Sandakerveien 116, NO-0402 Oslo, Norway
>


-- 
Regards,
Anthony



More information about the Qt-interest-old mailing list