In MSSQL when inside a multi-statement table valued function you can interact w/ the table as shown below.
CREATE FUNCTION dbo.test_func() RETURNS @table TABLE(id INT) AS
BEGIN
INSERT INTO @table(id)
SELECT 1 UNION SELECT 2 UNION SELECT 3
UPDATE @table SET id = -1 WHERE id = 3
RETURN
END
GO
Is there a way to accomplish this in Postgres 9.5? I'm not sure what to update as shown below.
CREATE FUNCTION test_func() RETURNS TABLE(id int) AS $$
BEGIN
return QUERY SELECT 1 UNION SELECT 2 UNION SELECT 3;
UPDATE ???? SET id = -1 WHERE id = 3;
END;
$$ LANGUAGE plpgsql STABLE;