Is it possible to create a user-defined function where input and output type may vary?

I would like to create a function that might be called with varchar or numeric input. The output type should match the input.

Is this possible?

I think I’ve worked it out. I’ve created the function multiple times once for each data type I want to handle.

Hi,

I would like to create a function that might be called with varchar or numeric input. The output type should match the input.

You’re talking about polymorphic functions which are indeed supported in postgres.
Refer here for more information.

Hope this helps.