[Interest] Use SQLite math functions (-DSQLITE_ENABLE_MATH_FUNCTIONS) like sin and cos?

Till Oliver Knoll till.oliver.knoll at gmail.com
Mon Oct 24 20:31:06 CEST 2022


Am 24.10.22 um 19:58 schrieb Till Oliver Knoll:
>
> However when compiled into my Qt 5.15.2 application with some current 
> "test code" like:.
>
> QSqlQueryquery1;
> query1.setForwardOnly(true);
> query1.prepare(
> "selectpower(l.latitude-48.0,2)+power((l.longitude-8.0)*cos(radians(48.0)),2)dist"
> "from location l;"
> );
> constboolsuccess=query1.exec();
>      if(success){
> 	...
> }else{
> qDebug()<<"SQL error:"<<query1.lastError().text()<<"- error code:"<<query1.lastError().nativeErrorCode();
> }
>
> I get:
>
> SQL error: "No query Unable to fetch row" - error code: ""
>
Just for the record: if I add the following "test code" to my own 
application:

QSqlQuery query1("select power(5, 2);"); ... ... << 
query1.lastError().text();

then I also get:

SQL error: "no such function: power Unable to execute statement" - error 
code: "1"

So it seems that when trying to generate a prepared statement the error 
message is different - but the root cause seems to be the same: "no math 
functions" available.

Cheers, Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221024/2e57a74f/attachment.htm>


More information about the Interest mailing list