Re: pl/pgsql and returning rows

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>, "wade" <wade(at)wavefire(dot)com>
Subject: Re: pl/pgsql and returning rows
Date: 2001-03-27 08:26:47
Message-ID: 00b701c0b697$ab527a40$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: "wade" <wade(at)wavefire(dot)com>

> create function get_details(int4) returns details as '
> declare
> ret details%ROWTYPE;
> site_rec record;
> cntct contacts%ROWTYPE;
> begin
> select into site_rec * sites_table where id = $1 limit 1;
> select into cntct * from contacts where id = site_rec.contact;
>
> -- and then i populate rows of ret.
> ret.name := cntct.name;
> ret.ip := site_rec.ip;
> .
> .
> .
> return ret;
> end;
> ' language 'plpgsql';
>
> now the problem is when is when I do a:
> SELECT get_details(55);
> all i get is a single oid-looking return value:
> get_details
> -------------
> 136295592
> (1 row)

Sorry - you can't return a row from a function at the present time (except
for trigger functions which are special) although I believe this is on the
todo list for a later 7.x release.

Just from the top of my head, you might try a view with a select rule,
although I'm not completely clear what your objectives are.

- Richard Huxton

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Marcin Kowalski 2001-03-27 09:03:07 pg_dump potential bug
Previous Message Justin Clift 2001-03-27 03:58:26 Re: Function Vanished