https://www.db -fiddle.com / f / 3dpbCYK7FeCMFcWRedBz17 / 2
Я пытаюсь запустить свою функцию, используя postgresql database
. Но я получаю эту ошибку
Schema Error: error: unterminated dollar-quoted string at or near "$total$ declare total integer;"
Schema Error: error: syntax error at or near "SELECT"
Schema Error: error: syntax error at or near "RETURN"
Schema Error: error: unterminated dollar-quoted string at or near "$total$ LANGUAGE plpgsql;"
Query Error: error: function totalrecords() does not exist
я могу проверить свою функцию онлайн?
CREATE TABLE test (
id INT
);
INSERT INTO test (id) VALUES (1);
INSERT INTO test (id) VALUES (2);
CREATE OR REPLACE FUNCTION totalRecords ()
RETURNS integer AS $total$
declare
total integer;
BEGIN
SELECT count(*) into total FROM test;
RETURN total;
END;
$total$ LANGUAGE plpgsql;