Thread: PL/PGSQL

PL/PGSQL

From
Andrzej Roszkowski
Date:
Hi!
I can't find any info about possible data types that can be returned from
procedure. I want to return tuple. When I use OPAQUE as a return type I
get error message that OPAQUE can be only returned from trigger. It is
possible to do this without triggers?

------------------------------------------------------------------------
Code reviews are like sex, just anyone can do it, but skill and training
can make you a lot better at it." - LJ 
Thomas



Re: PL/PGSQL

From
Alex Pilosov
Date:
You _can_ return a tuple by doing this:
create table foo(x int, y text);

create function bar() returns foo as '
...
';

The only thing is, you can't do much with such a function (currently), you
can only call it from a different function, and then break the result up:

foo v=bar();
do_something(v.x);
do_something(v.y);

-alex

On Tue, 5 Jun 2001, Andrzej Roszkowski wrote:

> Hi!
> I can't find any info about possible data types that can be returned from
> procedure. I want to return tuple. When I use OPAQUE as a return type I
> get error message that OPAQUE can be only returned from trigger. It is
> possible to do this without triggers?
> 
> ------------------------------------------------------------------------
> Code reviews are like sex, just anyone can do it, but skill and training
> can make you a lot better at it." - LJ 
> Thomas
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 
> 



Re: PL/PGSQL

From
Roberto Mello
Date:
On Tue, Jun 05, 2001 at 08:18:03AM +0200, Andrzej Roszkowski wrote:
> Hi!
> I can't find any info about possible data types that can be returned from
> procedure. I want to return tuple. When I use OPAQUE as a return type I
> get error message that OPAQUE can be only returned from trigger. It is
> possible to do this without triggers?
A little RTFM'ing wouldn't hurt. Currently you can't return tuples from "regular" PL/pgSQL  functions.
It heard this functionality will make it in 7.2.
-Roberto
-- 
+----| http://fslc.usu.edu USU Free Software & GNU/Linux Club |------+ Roberto Mello - Computer Science, USU -
http://www.brasileiro.net      http://www.sdl.usu.edu - Space Dynamics Lab, Developer    
 
Death to all fanatics!!!