From: | "Greg Quinn" <greg(at)officium(dot)co(dot)za> |
---|---|
To: | "'Michael Fuhr'" <mike(at)fuhr(dot)org> |
Cc: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Stored Procedure Question |
Date: | 2006-06-18 17:20:59 |
Message-ID: | 000a01c692fb$92ed0010$0b00a8c0@melt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)fuhr(dot)org]
Sent: Saturday, June 17, 2006 7:14 PM
To: Greg Quinn
Cc: pgsql-novice(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Damian C | 2006-06-19 01:30:19 | Postgres advice for Java/Hibernate project |
Previous Message | Greg Quinn | 2006-06-18 16:42:28 | Stored Procedure Question |