> If I add "close crs;" before the function returns, I get this: > > SELECT name, testcursor(testid) FROM test; > name | testcursor > ------+-------------------------------- > Bob | -Comment 1-Comment 2-Comment 3 > Mark | -Comment 1 > Tom | > (3 rows) > You got it. I was closing the cursor at the end of the function, but there were other possible returns in the middle. I changed the code to add close before each return and it works like a charm. I rushed together the example, or I should have caught that. Much thanks. Sim ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match