Re: Stored Procedure Question - Mailing list pgsql-novice

From Greg Quinn
Subject Re: Stored Procedure Question
Date
Msg-id 000a01c692fb$92ed0010$0b00a8c0@melt
Whole thread Raw
In response to Re: Stored Procedure Question  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Stored Procedure Question  (Michael Fuhr <mike@fuhr.org>)
List pgsql-novice
I am using 8.1. Now I am trying to create my function that returns multiple
columns. I have added an OUT parameter, but of what type must it be?

Any type I try to return it tells me that only one column can be returned.

Here is my function...

CREATE OR REPLACE FUNCTION "public"."sp_getcontacts" (out myrecord varchar)
RETURNS varchar AS
$body$
select firstname, lastname from contacts
$body$
LANGUAGE 'sql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;


-----Original Message-----
From: Michael Fuhr [mailto:mike@fuhr.org]
Sent: Saturday, June 17, 2006 7:14 PM
To: Greg Quinn
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Stored Procedure Question

On Sun, Jun 18, 2006 at 06:42:28PM +0200, Greg Quinn wrote:
> I am creating a simple FUNCTION that returns a few columns of data from a
> table.
>
> Just a question, in order to get this working, is there a general type I
can
> return, that I can use as a generic type for all my different functions?
>
> Or do I need to create a custom type for each FUNCTION?

In 8.1 you can use OUT or INOUT parameters; in earlier versions you
can create a custom type or use "record".  If you return "record"
then you'll need to provide a column list when you call the function.

--
Michael Fuhr



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.0/368 - Release Date: 6/16/2006



pgsql-novice by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Stored Procedure Question
Next
From: Bruno Wolff III
Date:
Subject: Re: Calculate difference between rows.