Why am I getting the following error?:
ERROR: query has no destination for result data
This is my function:
CREATE OR REPLACE FUNCTION public.SumASCII(
value character varying)
RETURNS int
LANGUAGE 'plpgsql'
COST 100.0
VOLATILE NOT LEAKPROOF
AS $function$
DECLARE finalResult int;
DECLARE tempChar character;
DECLARE valueLength int;
DECLARE tempResult int;
BEGIN
SELECT LENGTH(value) INTO valueLength;
SELECT finalResult = 0;
SELECT tempResult = 0;
DO
$do$
BEGIN
FOR i IN 1..valueLength LOOP
SELECT SUBSTRING(value, i, 1) INTO tempChar;
SELECT ASCII(tempChar) INTO tempResult;
SELECT finalResult += tempResult;
END LOOP;
END
$do$;
RETURN finalResult;
END;
$function$;
I've looked at other questions with the same error, but they don't seem to be related to my problem. I'm sure the answer is simple, but I just can't seem to see what the issue is here.. I'm declaring an int and I am returning an int..
Calling the function as follows:
SELECT SumASCII('abc')
:=.