Jeremy Nix <Jeremy.Nix@xxxxxxxxxx> writes: > I see what you're doing, but I'm not quite sure how to adapt it to what > I'm doing. Here's simplified snippet of my code. Can elaborate on how > I can return a recordset and the output parameters.? I suppose what you need is something like CREATE OR REPLACE FUNCTION Search (OUT TotalRecords int, OUT TotalPages int) RETURNS SETOF record AS $BODY$ FOR myRecord IN SELECT cols FROM searchResults LOOP TotalRecords := myRecord.TotalRecords; TotalPages := myRecord.TotalPages; RETURN NEXT; END LOOP; Anyway the point is that when you are using OUT parameters you do not say anything in RETURN or RETURN NEXT. Whatever you last assigned to the parameter variables is what's returned. regards, tom lane