pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Lane Van Ingen <lvaningen@esncc.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Can't Get SETOF Function to Work
Date: Tue, 1 Nov 2005 17:44:59 -0700
Message-ID: <20051102004459.GA88879@winnie.fuhr.org> (raw)
In-Reply-To: <EKEMKEFLOMKDDLIALABIMEILCEAA.lvaningen@esncc.com>
References: <EKEMKEFLOMKDDLIALABIMEILCEAA.lvaningen@esncc.com>

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



view thread (3+ messages)  latest in thread

Message-ID: <20051102004459.GA88879@winnie.fuhr.org>
Permalink:  ../20051102004459.GA88879@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20051102004459.GA88879@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, lvaningen@esncc.com
  Subject: Re: Can't Get SETOF Function to Work
  In-Reply-To: <20051102004459.GA88879@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox