4

I'd like to insert an input variable (integer) in a query SQL (@variable) using the algorithm postgresql execute sql in the graphical modeler of QGIS.

For example, in this kind of query

INSERT INTO table2 SELECT * FROM table1 WHERE ID = @variable;

where I should insert the variable in the input panel of the modeler and click play to do the query. I used pre-calculated value but with no success. Any suggestion?

1 Answer 1

6

You can build the SQL query, which should be a string. To do so, use a pre-calculated value and concatenate a string containing the query and the desired variable.

'select 1 + ' || @myval

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.