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.
gwarcherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel WilsonCommented:
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?
0
HuaMin ChenProblem resolverCommented:
See this example to call function

CREATE FUNCTION concat_lower_or_upper(a text, b text, uppercase boolean DEFAULT false)
RETURNS text
AS
$$
 SELECT CASE
        WHEN $3 THEN UPPER($1 || ' ' || $2)
        ELSE LOWER($1 || ' ' || $2)
        END;
$$
LANGUAGE SQL IMMUTABLE STRICT;

SELECT concat_lower_or_upper('Hello', 'World', true);
 concat_lower_or_upper 
-----------------------
 HELLO WORLD
(1 row)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gwarcherAuthor Commented:
Thanks for the help on calling the function.  I realized that the data types had to be unambigous.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.