0

I made a function in 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 I get:

ERROR: relation "a" does not exist LINE 2: from a help me

1 Answer 1

1

try this:

create or replace function get_source2(a text)
returns integer as
$$
declare
    geom geometry;
begin
  execute 'select get_source(geom) from '||quote_ident(a) into geom;
  return geom;
end;
$$
language plpgsql;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.