Avatar of gwarcher
gwarcher
 asked on

New to postgre, can't call a function properly

I am migrating GIS to postgre and I am trying to call a simple function to pad a datatype in order to standardize it's identity to other tables.  the column is districts, and it is currently a 2 or 3 digit numeric (in character).  My function will add two characters followed by 2 or34 leading zeroes.  So for example If the district was 23, it would then read AD0023 and in another table it might read BC0023 (different district entirely with same numeric designation.

Here is the function, I took this from a t-sql function that does the same thing.

CREATE OR REPLACE FUNCTION public.fnpad(
    padchar character,
    padlength integer,
    textin character varying)
  RETURNS character varying AS
$BODY$BEGIN
      RETURN string_agg(repeat(PadChar, PadLength), PadLength - char_length(TextIn) + 1, char_length(TextIn), TextIn);
      END;$BODY$
  LANGUAGE plpgsql VOLATILE

When I try to call it against a table it throws the error function does not exist.
PostgreSQL

Avatar of undefined
Last Comment
gwarcher

8/22/2022 - Mon
Daniel Wilson

Here's the doc page on calling functions.
http://www.postgresql.org/docs/9.4/static/sql-syntax-calling-funcs.html

If you don't see a mistake by looking at that, would you post the call that is failing?
ASKER CERTIFIED SOLUTION
Peter Chan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
gwarcher

ASKER
Thanks for the help on calling the function.  I realized that the data types had to be unambigous.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck