pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mig@utdt.edu
To: pgsql-sql@postgresql.org
Subject: Returning sets from functions?
Date: Sun, 23 Apr 2000 11:15:20 -0300
Message-ID: <200004231415.LAA04384@ant.utdt> (raw)

Consider
    create function followers(text) returns setof text as 
          'select id from ids where id > $1 '
          language 'sql';

The function seems to work OK:
    select followers('h');
does return all indexes after the index 'h'.

On the other hand,
    select * from ids where id in (select followers('h'));
produces the message
  ERROR:  An operand to the '=' operator returns a set of text,
        but '=' takes single values, not sets.

Apparently the phrase
    select followers('h');
returns a set with members which are 'setof text'. psql has no trouble
displaying all rows, but the parser does ...

So, my question is: can I produce a set in a function so that it
mimicks perfectly the return set of a select query?

I am using PG 6.5.3; is this already solved in the 7.0 beta?

Thanks

Miguel Sofer




view thread (3+ messages)  latest in thread

Message-ID: <200004231415.LAA04384@ant.utdt>
Permalink:  ../200004231415.LAA04384@ant.utdt/
Also on:    postgresql.org/message-id/200004231415.LAA04384@ant.utdt

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: mig@utdt.edu
  Subject: Re: Returning sets from functions?
  In-Reply-To: <200004231415.LAA04384@ant.utdt>
  References: <200004231415.LAA04384@ant.utdt>

* 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