gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Parameters for SQL files

Open corrado9999 opened this issue 7 years ago • 1 comments

Starting from ogr2ogr 2.1 it is possible to use as query a pointer to a text file "-sql @query.sql". It would be useful to be able to put some placeholder in the query and pass some additional argument to set their values.

For example,

$ cat query.sql
SELECT * FROM table WHERE id BETWEEN ? AND ?
$ ogr2ogr -sql @query.sql -sql-arg 42 -sql-arg 9999[...]

generates the same output of

$ ogr2ogr -sql "SELECT * FROM table WHERE id BETWEEN 42 AND 9999"  [...]

Of course, named arguments could be more useful for complex queries, especially when the same argument should be put in several places.

corrado9999 avatar Apr 09 '18 15:04 corrado9999

A very old feature request, would be great to be implemented!

latot avatar Aug 05 '24 14:08 latot