I've been trying to execute the following sql in postgres 9.6. But I get the error: syntax error at or near "row"
. Which would be on the line where CREATE AND REPLACE FUNCTION starts.
I've made a sqlfiddle too if you prefer that: http://sqlfiddle.com/#!17/48a30/1
CREATE TEMPORARY TABLE input (
id serial, certified boolean
);
CREATE TEMPORARY TABLE tests_person (
id serial, certified boolean
);
INSERT INTO input (id, certified) VALUES (DEFAULT, True), (DEFAULT, False), (DEFAULT, True), (DEFAULT, False), (DEFAULT, True), (DEFAULT, False);
CREATE OR REPLACE FUNCTION update_record(row input) RETURNS RECORD AS $$
UPDATE "tests_person"
SET certified=row.certified
WHERE certified=row.certified
RETURNING *
$$ LANGUAGE SQL;