QGIS Virtual Layer – Using Eval Function in Virtual Layer

qgisquerysqlvirtual-layer

I'm now trying to use the eval() function in a Virtual Layer in QGIS.
The version of QGIS is 3.28.4-Firenze, and it contains the SpatiaLite (version 5.0.1) which includes the eval() function as below.

SpatiaLite 5.0.1 SQL functions reference list: https://www.gaia-gis.it/gaia-sins/spatialite-sql-5.0.1.html

However, my Virtual Layer cannot execute the query because:

"Query preparation error on PRAGMA table_info(_tview): no such function: eval".

Before the execution of SQL, I set the path using set SPATIALITE_SECURITY=relaxed in OSGeo4W Shell.

Is there any solution?

Best Answer

This is an interesting question that has piqued my interest. As I'm working in QGIS Windows, I set SPATIALITE_SECURITY=relaxed in the global Windows environment.

After many trials and errors, I found a syntax that worked in a virtual layer query:

select eval('select mycol from mytable',',')
from mytable
limit 1
Related Question