0

Trying to create my first PostgreSQL function, I don't understand why I can't call this function.

CREATE FUNCTION public."SampledImpCountToOriginal"(IN integer)
    RETURNS numeric
    LANGUAGE 'plpgsql'
    
AS $BODY$
BEGIN
    RETURN CASE WHEN $1 > 4 THEN EXP(POW($1 - 1.88, 1/2.3)) ELSE $1 END;
END;
$BODY$;

SELECT SampledImpCountToOriginal(5)

ERROR: function sampledimpcounttooriginal(integer) does not exist LINE 1: SELECT SampledImpCountToOriginal(5) ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. SQL state: 42883 Character: 8

Calling from the same database I created it in, tried changing owner, can't figure it out. The function is listed in pgAdmin as SampledImpCountToOriginal(IN integer).

1 Answer 1

2

You have to call like this - SELECT "SampledImpCountToOriginal"(5)

When ever you use Double Quotes "" to create Function, you have to use in calling process. like -

SELECT public."SampledImpCountToOriginal"(
    <integer>
)

If you don't use double quotes "" to calling your created function with "". it consider different function.

SELECT public.sampledimpcounttooriginal(
    <integer>
)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Lifesaver. I dropped the function and redefined it without the quotes. I originally created the function with pgAdmin and it inserted the quotes... confusing behavior.

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.