Re: Stored Procedure / function and their result

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Alain Roger <raf(dot)news(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Stored Procedure / function and their result
Date: 2007-03-19 13:02:04
Message-ID: 20070319130204.GC28777@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 19, 2007 at 01:54:14PM +0100, Alain Roger wrote:
> Hi,
>
> I would like to know if there is a better way how to retrieve result from a
> stored procedure (function) than to use 'AS res(col1 varchar, col2
> timestamp,..)'

Sure, create a type with the relevent field name and use that in you
function declaration:

CREATE TYPE mytype AS S res(col1 varchar, col2 timestamp,..);

> for example, here is a stored procedure :
> CREATE OR REPLACE FUNCTION SP_A_003(username VARCHAR)
> RETURNS SETOF RECORD AS

And change that to:

RETURNS SETOF mytype AS

And you're done.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Walter Vaughan 2007-03-19 13:07:02 Re: UPGRADATION TO 8.1
Previous Message Alain Roger 2007-03-19 12:54:14 Stored Procedure / function and their result