Make set= generate (...) VALUES (...) inside INSERT INTO statements, because SET isn't allowed in INSERT INTO by PostgreSQL.