出现奇怪的错误,从功能上升:
CREATE OR REPLACE FUNCTION addAnswer(bodyR VARCHAR, userIdR BIGINT, qId BIGINT)
RETURNS BIGINT AS $$
DECLARE
ret BIGINT;
author_idR BIGINT;
BEGIN
author_idR := (SELECT "a"."author_id" FROM "question" "a" WHERE "a"."id"=qId);
IF (author_idR = userIdR ) THEN
RAISE EXCEPTION "Question author and answer author shouldn't match!";
ENDIF;
INSERT INTO "answer"("body", "author_id", "created_at", "question_id") VALUES (bodyR, userIdR, CURRENT_TIMESTAMP, qId);
ret := LASTVAL();
RETURN ret;
END
$$ LANGUAGE plpgsql;
我收到的错误声明:
ERROR: unrecognized exception condition "Question author and answer author shouldn't match!"
CONTEXT: compilation of PL/pgSQL function "addanswer" near line 9
********** Error **********
ERROR: unrecognized exception condition "Question author and answer author shouldn't match!"
SQL state: 42704
Context: compilation of PL/pgSQL function "addanswer" near line 9
感谢任何建议,谢谢。
答案 0 :(得分:2)
您不应使用"
来说明异常文本。请改用'
。
请参阅https://www.postgresql.org/docs/9.3/static/plpgsql-errors-and-messages.html