I am using PostgreSQL with PostGis. I am executing a query like this:
select st_geomfromtext('point(22 232)',432)
It works fine. But now I want to take a value through a query. for example:
select st_geomfromtext('point((select x from data_name where id=1) 232)' , 432)
Here data_name
is some table I am using and x
stores some values. Now query inside is treated as a string and no value is returned.
Please help.
ERROR: syntax error at or near "select"
A function is a set of SQL statements that perform a specific task. Functions foster code reusability. If you have to repeatedly write large SQL scripts to perform the same task, you can create a function that performs that task.
Select statements included within a function cannot return data to a client. FUNCTION SQL SERVER. Attachments: Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.
Functions only work with select statements. Functions can be used anywhere in SQL, like AVG, COUNT, SUM, MIN, DATE and so on with select statements. Functions compile every time. Functions must return a value or result.
Try this:
select st_geomfromtext('point(' || x || ' 232)', 432) from data_name where id=1
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