From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Craig Bryden <postgresql(at)bryden(dot)co(dot)za> |
Cc: | pgsql <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Functions that return RECORD type |
Date: | 2005-01-14 09:29:00 |
Message-ID: | 41E790DC.3010907@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Craig Bryden wrote:
> When I run select * from GetAccountInfo (100) I get the following
> error message: ERROR: a column definition list is required for functions
> returning "record"
>
> please can someone explain to me how to create a column definition list.
CREATE FUNCTION foo() RETURNS SETOF RECORD AS
'SELECT 1::int,2::int,''A''::text;'
LANGUAGE sql;
SELECT * FROM foo() AS (a int, b int, c text);
a | b | c
---+---+---
1 | 2 | A
(1 row)
The other way (which I prefer) is to define a type and change the
function definition:
CREATE TYPE foo_res_type AS (a int, b int, c text);
CREATE FUNCTION foo() RETURNS SETOF foo_res_type ...
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Christian Kratzer | 2005-01-14 09:32:18 | Re: OID Usage |
Previous Message | Bo Lorentsen | 2005-01-14 09:07:33 | Re: OID Usage |