Home > Software design >  PostgreSQL: Function does not exist
PostgreSQL: Function does not exist

Time:09-17

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

CodePudding user response:

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