PostgreSQl function return multiple dynamic result sets
问题 I have an old MSSQL procedure that needs to be ported to a PostgreSQL function. Basically the SQL procedure consist in a CURSOR over a select statement. For each cursor entity i have three select statements based on the current cursor output. FETCH NEXT FROM @cursor INTO @entityId WHILE @@FETCH_STATUS = 0 BEGIN SELECT * FROM table1 WHERE col1 = @entityId SELECT * FROM table2 WHERE col2 = @entityId SELECT * FROM table3 WHERE col3 = @entityId END The tables from the SELECT statements have