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

alexander golks alex at golks.de
Wed Mar 11 10:36:39 CET 2015


Am Wed, 11 Mar 2015 10:29:41 +0100
schrieb Guido Seifert <wargand at gmx.de>:

> 
> > 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. 

you can try to debug into the driver and see what happens, e.g. stepping into the QSqlQuery::exec(). this way you could verify that it's either the driver or the database.

perhaps a postgres user can give more informations, when you provide the QSqlError::text() from the failing statement.

> > 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
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

alex

-- 
/*
 *  Q:  Why don't Scotsmen ever have coffee the way they like it?
 *  A:  Well, they like it with two lumps of sugar.  If they drink
 *    it at home, they only take one, and if they drink it while
 *    visiting, they always take three.
 */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150311/ccee5604/attachment.sig>


More information about the Interest mailing list