[Interest] QSqlQuery... bindValue does not work for CREATE TABLE .... AS SELECT....

Guido Seifert wargand at gmx.de
Wed Mar 11 10:29:41 CET 2015


> works at my side, qt4.8.6:
>   query.prepare("CREATE TEMP TABLE selectseriestable AS SELECT title FROM titlegroup,title "
>     "WHERE titlegroup.seriesID=(SELECT seriesid FROM series WHERE series=:series AND version=:version) AND titlegroup.titleID=title.titleID;");
>   QString series="bla";
>   QString version="blabla";
>   query.bindValue(":series",series);
>   query.bindValue(":version",version);
> 
> besides that my ms sql server don't like the syntax...

There is an alternative syntax for the same goal using SELECT INTO... Does not work for me either. Exactly the same problem. 

> in my case the QSqlQuery emulates preparing and binding, but the query is prepared successfully and the values are bound. and the 
> statement is executed by the sql server.

Maybe a problem of the postgresql driver. 

> i think in view of the drivers theres no difference in the exact statement, whether you have a insert, create, whatever, 
> is of no concern.

That's what I thought, too. But neither CREATE TEMP TABLE... AS SELECT nor SELECT * INTO .... FROM works for me if I use
bound values. Those statement are the only, which give me this trouble. And since you say it works for you on qt4.8.6 and it works
for me if I remove the bound values, I doubt it is a bug on my side.

Fortunately it is not a show stopper for me. Though the workaround looks a but ugly. 

Thanks for trying.

Guido



More information about the Interest mailing list