1

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?

2

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

| improve this answer | |
  • Thank you!! It works! – Mark Jul 8 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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