Пытаюсь перенести функцию sql server в postgres выдает ошибку синтаксиса:
ERROR: syntax error at or near "_count"
по документации вроде правильно написал doc assignment
_count := (SELECT count(score) from PaperReviewing wh...
(Обновлено)вот код целиком, теперь вот здесь ошибка
syntax error at end of input
и указывает на $$
CREATE OR REPLACE FUNCTION SubmitReview(_paper_id INT, _reviewer_id INT, _score INT)
RETURNS VOID AS $$
DECLARE
_mark float;
_count INT;
BEGIN
_mark := 0;
_count := 0;
IF Exists(Select paper_id, reviewer_id from PaperReviewing where paper_id=_paper_id and reviewer_id =_reviewer_id )AND _score in (1,2,3,4,5,6,7) then
UPDATE PaperReviewing
SET score = _score;
_count := (SELECT count(score) from PaperReviewing where paper_id = _paper_id );
If ( _Count)>=3 then
_mark := cast( (Select sum(score) from PaperReviewing where paper_id = _paper_id) as float)/_Count;
IF _mark>4 then
UPDATE Paper
SET accepted=1
where Id = @paper_id;
else
UPDATE Paper
Set accepted = 0
where Id = @paper_id;
end if;
else
RAISE EXCEPTION 'Not implemented yet';
END IF;
END;
$$ LANGUAGE plpgsql;