Re: Returning types - PL-PgSql functions

From: "Joshua b(dot) Jore" <josh(at)greentechnologist(dot)org>
To: Vilson farias <vilson(dot)farias(at)digitro(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Returning types - PL-PgSql functions
Date: 2002-05-28 20:39:00
Message-ID: Pine.BSO.4.44.0205281535520.22748-100000@kitten.greentechnologist.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sure you can, I wouldn't nessessarily recommend it. rec_tmp must be a
table somewhere so it can be a 'type', you get the values from the record
by using syntaxt like SELECT col1(teste_tmp(1)), col2(teste_tmp(1)),
col3(teste_tmp(1));

You could also return a CURSOR but I've never tried that (I access
PostgreSQL from perl's DBI which doesn't support a cursor return type).

Joshua b. Jore ; http://www.greentechnologist.org ; 10012 11010 11022
10202 1012 2122 11020 10202 10202 11002 1020 1012 11102 11102 11102 1201
11001 11002 10211 11020 10202 10202 11002 11021 1201 11010 11020 10211

On Tue, 28 May 2002, Vilson farias wrote:

> Greetings,
>
> I would like to know if it's possible to return a record from a pl-pgsql
> function.
>
> The procedure I did is bellow and of course doesn't work. Is there some
> possibility or work-around?
>
> CREATE FUNCTION teste_tmp(INT4)
> RETURNS RECORD AS '
> DECLARE
> rec_tmp record;
> BEGIN
> SELECT
> INTO rec_tmp
> 1 as col1, ''teste'' as col2, now() as col3 ;
>
> RETURN rec_tmp;
> END;
> '
> LANGUAGE 'plpgsql';
>
> Best regards,
>
> ----------------------------------------------------------------------------
> ----
> Jos Vilson de Mello de Farias
> Software Engineer
>
> Dgitro Tecnologia Ltda - www.digitro.com.br
> APC - Customer Oriented Applications
> E-mail: vilson(dot)farias(at)digitro(dot)com(dot)br
> Tel.: +55 48 281 7158
> ICQ 11866179
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Robert Norris 2002-05-28 21:08:40 Re: How to cripple a postgres server
Previous Message Vilson farias 2002-05-28 20:15:58 Returning types - PL-PgSql functions