Qt-interest Archive, February 2008
QSql Query execution problem
Message 1 in thread
Hello
I am facing problems while trying to execute an QSqlQuery using the sample
code below:
*QSqlQuery _query(myQSqlDatabase);
_query.prepare("SELECT address_code FROM address WHERE address_geometry[0] =
xCoord");
_query.bindValue("xCoord", 111.1);
_query.exec();
Meanwhile it is possible to execute the above query inside my database
server, which is PostgreSQL, and
it is **also **possible to execute the query with success when using the
following expression:
QSqlQuery _query(**"SELECT address_code FROM address WHERE
address_geometry[0] = 111.1", myQSqlDatabase);
which is regarded as a bad way to execute a QSqlQuery..
Is this related with binding values or with double precision values?
Any ideas? Thanks in advance.
*
--
[ signature omitted ]
Message 2 in thread
Nikos Geronitidis wrote:
> Hello
>
> I am facing problems while trying to execute an QSqlQuery using the sample
> code below:
>
> *QSqlQuery _query(myQSqlDatabase);
> _query.prepare("SELECT address_code FROM address WHERE address_geometry[0] =
> xCoord");
You seem to have omitted the ":" before the bind parameter xCoord.
These are required.
--
[ signature omitted ]
Message 3 in thread
Thanks for your replying.
I apologize for not sending the correct code.
This doesn't seem to be the problem as i have corrected the name and still
the query cannot be executed with success.
This is the exact query code that cannot be executed:
*QSqlQuery _query(_sqlDb);
_query.prepare("SELECT address_id FROM address WHERE address_geometry[0]
= :address_geometry[0]");
_query.bindValue(":address_geometry[0]", 1239.9);
* _query.exec();
and this is the query, which can be executed with success inside the
database and also from my client application:
*QSqlQuery _query(**SELECT address_id FROM address WHERE address_geometry[0]
= 1239.9", **_sqlDb);
_query.exec();*
*
*
On Mon, Feb 25, 2008 at 4:26 PM, Stephen Collyer <scollyer@xxxxxxxxxxxxxxxx>
wrote:
> Nikos Geronitidis wrote:
> > Hello
> >
> > I am facing problems while trying to execute an QSqlQuery using the
> sample
> > code below:
> >
> > *QSqlQuery _query(myQSqlDatabase);
> > _query.prepare("SELECT address_code FROM address WHERE
> address_geometry[0] =
> > xCoord");
>
> You seem to have omitted the ":" before the bind parameter xCoord.
> These are required.
>
> --
> Regards
>
> Steve Collyer
> Netspinner Ltd
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]
Message 4 in thread
Nikos Geronitidis wrote:
> Thanks for your replying.
> I apologize for not sending the correct code.
> This doesn't seem to be the problem as i have corrected the name and still
> the query cannot be executed with success.
> This is the exact query code that cannot be executed:
> *QSqlQuery _query(_sqlDb);
> _query.prepare("SELECT address_id FROM address WHERE address_geometry[0]
> = :address_geometry[0]");
> _query.bindValue(":address_geometry[0]", 1239.9);
> * _query.exec();
1. What error message do you see ?
2. Have you tried with a bind name that does not contain [ chars ?
I'm not sure that these are going to legal here.
Try "address_geometry_0" instead.
--
[ signature omitted ]
Message 5 in thread
You are right. The problem solved after replacing the brackets and setting a
new name for the bound value, like the one
you suggested..(address_geometry_0)
Thanks again.
On Mon, Feb 25, 2008 at 5:54 PM, Stephen Collyer <scollyer@xxxxxxxxxxxxxxxx>
wrote:
> Nikos Geronitidis wrote:
> > Thanks for your replying.
> > I apologize for not sending the correct code.
> > This doesn't seem to be the problem as i have corrected the name and
> still
> > the query cannot be executed with success.
> > This is the exact query code that cannot be executed:
> > *QSqlQuery _query(_sqlDb);
> > _query.prepare("SELECT address_id FROM address WHERE
> address_geometry[0]
> > = :address_geometry[0]");
> > _query.bindValue(":address_geometry[0]", 1239.9);
> > * _query.exec();
>
> 1. What error message do you see ?
>
> 2. Have you tried with a bind name that does not contain [ chars ?
> I'm not sure that these are going to legal here.
> Try "address_geometry_0" instead.
>
> --
> Regards
>
> Steve Collyer
> Netspinner Ltd
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]