going gaga on creating an aggregate...

Поиск
Список
Период
Сортировка
От Christian Fritze
Тема going gaga on creating an aggregate...
Дата
Msg-id 200004151928.VAA02025@chatsubo.sprawl.de
обсуждение исходный текст
Список pgsql-sql
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';CREATEfoodb=>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 = '');CREATEfoodb=> select test_agg_1(textvar) from testtable;ERROR:  ExecAgg:
novalid 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;DROPfoodb=> create aggregate test_agg_1 (        basetype = text,         stype1
=text,         sfunc1 = test_func_1);CREATEfoodb=> select test_agg_1(textvar) from testtable;test_agg_1----------
 
(1 row)                                    

which is just as silly, because

foodb=> select textvar from testtable;textvar-------foobarcom(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.--
 




В списке pgsql-sql по дате отправления:

Предыдущее
От: Jerome Alet
Дата:
Сообщение: Re:
Следующее
От: Christian Fritze
Дата:
Сообщение: Re: going gaga on creating an aggregate... [solved of course...]