is it possible to refer to a column/table name by using a string? Something like SELECT * FROM 'my_table'::table_name_t
?
The reason I'm asking: I have a table geometry_columns with some geometry tables. And I would like to know which objects are within a certain radius.
Thanks, Philip
You will need a (stored) function to achieve this. The function takes the table name as an argument, creates the SQL dynamically and then returns the result of the SELECT based on that query.
here are some examples (not exactly what you need, but they should get you headed in the right direction):
http://forums.devshed.com/postgresql-help-21/plpgsql-variable-representing-table-name-137201.html
Dynamic column in SELECT statement postgres
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With