Dan
Dan

Reputation: 864

PostgreSQL: Function does not exist

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).

Upvotes: 0

Views: 5773

Answers (1)

Satyanand bhardwaj
Satyanand bhardwaj

Reputation: 355

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>
)

Upvotes: 2

Related Questions