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 35904DB935 for ; Tue, 1 Nov 2005 22:38:54 -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 14044-06 for ; Wed, 2 Nov 2005 02:38:50 +0000 (GMT) Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net [66.173.159.28]) by svr1.postgresql.org (Postfix) with ESMTP id DAA42DB3C0 for ; Tue, 1 Nov 2005 20:58:42 -0400 (AST) Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with Microsoft SMTPSVC(5.0.2195.6713); Tue, 1 Nov 2005 19:58:46 -0500 From: "Lane Van Ingen" To: "Michael Fuhr" Cc: Subject: Re: Can't Get SETOF Function to Work Date: Tue, 1 Nov 2005 19:55:05 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 In-Reply-To: <20051102004459.GA88879@winnie.fuhr.org> Importance: Normal X-OriginalArrivalTime: 02 Nov 2005 00:58:46.0418 (UTC) FILETIME=[9408EF20:01C5DF48] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.03 required=5 tests=[AWL=0.030] X-Spam-Score: 0.03 X-Spam-Level: X-Archive-Number: 200511/18 X-Sequence-Number: 23270 It worked perfectly! Thank you so much for your help! -----Original Message----- From: Michael Fuhr [mailto:mike@fuhr.org] Sent: Tuesday, November 01, 2005 7:45 PM To: Lane Van Ingen Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Can't Get SETOF Function to Work 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