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(
textin character varying)
RETURNS character varying AS
RETURN string_agg(repeat(PadChar, PadLength), PadLength - char_length(TextIn) + 1, char_length(TextIn), TextIn);
LANGUAGE plpgsql VOLATILE
When I try to call it against a table it throws the error function does not exist.