From: Christian Fritze <The.Finn@sprawl.de>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: going gaga on creating an aggregate...
Date: Sat, 15 Apr 2000 21:28:54 +0200
Message-ID: <200004151928.VAA02025@chatsubo.sprawl.de> (raw)
Hi!
This one's really driving me mad. Maybe one of you can shed some light
on it. If I'm just too dumb to see, then beat me, forgive me and tell
me how it's done anyway. Thanks in advance!
I'd like to concatenate all values of a text attribute returned by some
select statement. So first I define a function to concatenate two text
parameters (and no, I don't just use textcat because I want to be sure
about the extra blank...)
foodb=> create function test_func_1(text, text) returns text as
'select ($1 || \' \') || $2' language 'sql';
CREATE
foodb=> select test_func_1('foo', 'bar');
test_func_1
-----------
foo bar
(1 row)
Ah, seems to work fine... Now for the aggregation:
foodb=> create aggregate test_agg_1 (
basetype = text,
stype1 = text,
sfunc1 = test_func_1,
initcond1 = '');
CREATE
foodb=> select test_agg_1(textvar) from testtable;
ERROR: ExecAgg: no valid transition functions??
What's that beast talking here???
If I leave the initcond1 out of the aggregate's definition, I get
the following:
foodb=> drop aggregate test_agg_1 text;
DROP
foodb=> create aggregate test_agg_1 (
basetype = text,
stype1 = text,
sfunc1 = test_func_1);
CREATE
foodb=> select test_agg_1(textvar) from testtable;
test_agg_1
----------
(1 row)
which is just as silly, because
foodb=> select textvar from testtable;
textvar
-------
foo
bar
com
(3 rows)
The things mentioned above happen under postgres 6.4.2.
On a 6.5.3 I just got:
foodb=> select test_agg_1(textvar) from testtable;
ERROR: SQL-language function not supported in this context.
Huh??? What context is meant here? And why no SQL functions here?
Is my wish so exotic or am I just missing the point?
Greetings
Christian
--
"The sky above the port was the color of television,
tuned to a dead channel."
-- W.G. --
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: The.Finn@sprawl.de
Subject: Re: going gaga on creating an aggregate...
In-Reply-To: <200004151928.VAA02025@chatsubo.sprawl.de>
References: <200004151928.VAA02025@chatsubo.sprawl.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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