X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 63BACDB449 for ; Tue, 1 Nov 2005 20:45:40 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67302-04 for ; Wed, 2 Nov 2005 00:45:36 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 45B89DB34B for ; Tue, 1 Nov 2005 20:45:38 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id jA20j0JQ013276 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Nov 2005 17:45:03 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id jA20ixr6088929; Tue, 1 Nov 2005 17:44:59 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id jA20ixfQ088928; Tue, 1 Nov 2005 17:44:59 -0700 (MST) (envelope-from mfuhr) Date: Tue, 1 Nov 2005 17:44:59 -0700 From: Michael Fuhr To: Lane Van Ingen Cc: pgsql-sql@postgresql.org Subject: Re: Can't Get SETOF Function to Work Message-ID: <20051102004459.GA88879@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006] X-Spam-Score: 0.006 X-Spam-Level: X-Archive-Number: 200511/16 X-Sequence-Number: 23268 On Tue, Nov 01, 2005 at 04:38:12PM -0500, Lane Van Ingen wrote: > Have tried perhaps 20+ alternatives on this plpgsql function, but can't get > it to work. Suspect I have done something wrong either with RETURN values, > creating of a type, or (most likely) use of ROW(). > ... > CREATE OR REPLACE FUNCTION router_history() > RETURNS SETOF typ_history_rec_format AS > $BODY$ > DECLARE > returnValue RECORD; Try declaring returnValue as typ_history_rec_format instead of RECORD. > select into returnValue ROW(workarea.interface,workarea.updatedTime, > work_rftype,workarea.rfspeed); Get rid of the record constructor: select into returnValue workarea.interface, workarea.updatedTime, work_rftype, workarea.rfspeed; Using your code with the above two changes and some canned data, I got the function to work (where "work" means it ran and returned some rows -- I didn't look closely at the logic to see if the results were actually correct ;-). -- Michael Fuhr