Re: Definition of return types for own functions?

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Subject: Re: Definition of return types for own functions?
Date: 2006-09-28 10:46:50
Message-ID: 20060928104650.GB17869@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Thu, dem 28.09.2006, um 12:31:37 +0200 mailte Martijn van Oosterhout folgendes:
> On Thu, Sep 28, 2006 at 10:15:19AM +0200, A. Kretschmer wrote:
> > am Thu, dem 28.09.2006, um 9:46:29 +0200 mailte Matthias(dot)Pitzl(at)izb(dot)de folgendes:
> > > Hello all!
> > >
> > > Is it possible to define a complex return type like a record in a function
> > > without having some table around with the needed structure of the return
> > > values?
> >
> > Yes, you can define a new type:
> >
> > CREATE TYPE name AS
> > ( attribute_name data_type [, ... ] )
>
> Also, in more recent versions (8.1 I think) you can use OUT parameters
> to create anonymous types.

Oh yes, thanks. A little example:

test=# create function foo(OUT b text, OUT i int) as $$begin b := 'foo'; i:=1; end; $$ language plpgsql;
CREATE FUNCTION
test=*# select * from foo();
b | i
-----+---
foo | 1
(1 row)

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
eMail schreiben kann jeder -- lernen: http://webserv/email/email.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2006-09-28 12:07:32 Re: text to point conversion not working. ( cannot cast
Previous Message Martijn van Oosterhout 2006-09-28 10:31:37 Re: Definition of return types for own functions?