andrew andrew - 3 days ago 5
SQL Question

pgadmin, sql, function inputday by table name

I made a function im pgadmin




create or replace function get_source2(a text)

returns integer as

$$
declare

a text;

geom geometry;

begin

select get_source(geom)

from a;


end

$$

language plpgsql;





I want input a by table name
How can I do?
I try to like this

select get_source2('postgis.center')
but
ERROR: relation "a" does not exist
LINE 2: from a
help me

Answer

You need to call it as part of a regular select statement:

select get_source(geom), name, place
from location;

But that will be very inefficient as you are running the select inside the function for each and every row in the location table.

Comments