I'm getting a syntax error but having issues identifying what exactly the issue is. I'm not sure if I'm misunderstanding things here -- but it looks like the INSERT INTO is breaking, but only when it's in the function.
I'm running the below through Hasura:
CREATE OR REPLACE FUNCTION custom_q_into_selected()
RETURNS trigger AS $BODY$
BEGIN
IF NEW.is_custom = true THEN
INSERT INTO selected_question(book_id,question_id)
VALUES(NEW.custom_for_book_id,NEW.id);
END IF;
RETURN NEW;
END;
$BODY$ LANGUAGE plpgsql;
Keep getting this error when I run this:
postgres-error: syntax error at or near "\"
Database logs:
CREATE OR REPLACE FUNCTION custom_q_into_selected() \r
RETURNS trigger AS $BODY$\r
BEGIN\r
IF NEW.is_custom THEN \r
INSERT INTO selected_question(book_id,question_id) VALUES(NEW.custom_for_book_id,NEW.id);\r
END IF;\r
RETURN NEW;\r
END;\r
$BODY$ LANGUAGE plpgsql;\r
Any help is appreciated.