pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brett Schwarz <schwarz@PacketVideo.COM>
To: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: FUNCTION returing multiple rows
Date: Tue, 2 Jan 2001 13:15:12 -0800
Message-ID: <72660A24B978D411BB8A00B0D03DFE0115117D@misty.packetvideo.com> (raw)

I have seen in the postings that it is not possible to return multiple rows
from a function.

However, when I look at the programmers guide (Ch. 4), it almost leads me to
believe otherwise:

---------------------8<---------------------------------------------------
The following more interesting example takes a single argument of type EMP,
and retrieves multiple results: 

select function hobbies (EMP) returns set of HOBBIES
    as 'select (HOBBIES.all) from HOBBIES
        where $1.name = HOBBIES.person'
    language 'sql';
  
---------------------8<---------------------------------------------------


I know that it only says 'multiple results' but with the 'HOBBIES.all', it
almost leads me to believe that it is retrieving all of the fields. Is 'all'
a keyword, or is this just one field in HOBBIES?

Also, is there any type of function return multiple rows (plpgsql, pltcl,
etc)?

If not, then is there anyway to fake it out to do this. Could I concatenate
the fields together to form one field per row. This would look like multiple
results of 1 field to PG. Also, if I did this, is there a delimiter I should
use?

for example:

select field1 || ':' || field2 || ':' || field3 from some_table;

Where ":" is the delimiter to send back.

Sorry for this question, but I am porting over an app from Oracle, and they
do not want to change the java code that calls this; so I need to make this
work somehow.

thanks,

--brett




view thread (2+ messages)  latest in thread

Message-ID: <72660A24B978D411BB8A00B0D03DFE0115117D@misty.packetvideo.com>
Permalink:  ../72660A24B978D411BB8A00B0D03DFE0115117D@misty.packetvideo.com/
Also on:    postgresql.org/message-id/72660A24B978D411BB8A00B0D03DFE0115117D@misty.packetvideo.com

 · 

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: schwarz@PacketVideo.COM
  Subject: Re: FUNCTION returing multiple rows
  In-Reply-To: <72660A24B978D411BB8A00B0D03DFE0115117D@misty.packetvideo.com>
  References: <72660A24B978D411BB8A00B0D03DFE0115117D@misty.packetvideo.com>

* 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