I have some problems using the "Execute SQL" algorithm (in General Vector Tool) in the Processing Toolbox. No problem when I've got only 1 input table, but when I try to select 2 tables as input data I get an error: virtual: Referenced table input2 in query not found!
For background information my SQL expression (works fine with add virtual layers):
select makepoint((st_line_locate_point(p.geometry, a.geometry)*st_length(a.geometry)) /*:real*/,"Z" /*:real*/,2154) as geometry
from 'input1' as a, 'input2' as p
1 Answer 1
This problem is due to a bug in the "ExecuteSQL.py" script, where an index wasn't being incremented (see the bug report here). That bug report says the issue has been resolved, so I'm not sure why it's still happening on my machine but the fix itself was easy enough to do by hand, following the fix shown here.
Basically it involves adding the following line to "ExecuteSQL.py" after line 106:
layerIdx += 1
I just made the change, tried it and it worked.
-
I added the line in ExecuteSQL.py in QGIS 2.18.28, but an python error appears when loading Qgis
layerIdx += 1 IndentationError: unexpected indent
Leehan– Leehan2019年03月04日 08:49:39 +00:00Commented Mar 4, 2019 at 8:49 -
Looks like you don't have the correct number of spaces at the front of your line. This matters because indentation is how Python keeps track of nesting and loops etc.Don– Don2019年03月04日 15:30:06 +00:00Commented Mar 4, 2019 at 15:30
-
so obvious...Thanks. But the issue is before that : in the graphic modeler
ExecuteSQL
can't use a layer previously generated withpoints layer from table
. It is a part of a bug that is not fixed so far according to your link (?).Leehan– Leehan2019年03月05日 12:53:45 +00:00Commented Mar 5, 2019 at 12:53 -
@Leehan for the Graphical Modeler you might want to look at this question. The bug report I referenced was reopened about three months ago, because of problems with the Graphical Modeler. I just tried using ExecuteSQL: it works from the Processing Toolbox, but not within the Graphical Modeler, so maybe these problems require different fixes.Don– Don2019年03月05日 15:05:36 +00:00Commented Mar 5, 2019 at 15:05
Explore related questions
See similar questions with these tags.
Toolbox -> GDAL/OGR -> [OGR] Miscellaneous -> Execute SQL
. At least in 2.14 and 2.16 it is.