pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedReturning result sets.
2+ messages / 2 participants
[nested] [flat]
* Returning result sets.
@ 2003-02-14 01:44 Michael Weaver <mweaver@corpusglobe.com>
0 siblings, 1 reply; 2+ messages in thread
From: Michael Weaver @ 2003-02-14 01:44 UTC (permalink / raw)
To: pgsql-sql; pgsql-novice@postgresql.org
How do I declare a stored function to return a result set. (ie set of
records)
I can define a function returning " setof record "
but I get an error:
A column definition list is required for functions returning RECORD
The docs(7.3) seem to think that this should be ok.
so what is wrong?
I have managed to get it to work by first declaring a type for the record
set:
CREATE TYPE sp_report_retail_sales_type AS (a int8, b int8, c numeric, d
numeric);
TIA,
Mike Weaver
Software Developer
5, 42 Ladner Street
O'Connor, WA, 6163
All correspondence:
PO Box Y3502
East St Georges Terrace
Perth WA 6832
P: (+618) 9331 2700
F: (+618) 9331 3733
M: 0403 385 181
W: http://www.corpusglobe.com/
E: mweaver@corpusglobe.com
This email is intended only for the use of the individual or entity named
above and may contain information that is confidential. If you are not the
intended recipient, you are hereby notified that any dissemination,
distribution or copying of this email is strictly prohibited. When addressed
to our clients, any opinions or advice contained in this email are subject
to the terms and conditions expressed in the governing Corpus Globe client
engagement letter. If you have received this Email in error, please notify
us immediately by return email or telephone +61 8 9331 2700 and destroy the
original message. Thank You.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] Returning result sets.
@ 2003-02-14 01:57 Joe Conway <mail@joeconway.com>
parent: Michael Weaver <mweaver@corpusglobe.com>
0 siblings, 0 replies; 2+ messages in thread
From: Joe Conway @ 2003-02-14 01:57 UTC (permalink / raw)
To: Michael Weaver <mweaver@corpusglobe.com>; +Cc: pgsql-sql; pgsql-novice@postgresql.org
Michael Weaver wrote:
> How do I declare a stored function to return a result set. (ie set of
> records)
>
> I can define a function returning " setof record "
> but I get an error:
>
> A column definition list is required for functions returning RECORD
>
> The docs(7.3) seem to think that this should be ok.
> so what is wrong?
You need to look a bit closer at the docs ;-)
After declaring myfunc() to return setof record, try:
select * from my_func() AS (a int8, b int8, c numeric, d numeric);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
missing - "the column definition list"
HTH,
Joe
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-02-14 01:57 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-14 01:44 Returning result sets. Michael Weaver <mweaver@corpusglobe.com>
2003-02-14 01:57 ` Joe Conway <mail@joeconway.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox