Array operator "sum array values" + matching dimensions - Mailing list pgsql-general

From Scara Maccai
Subject Array operator "sum array values" + matching dimensions
Date
Msg-id 520692.23475.qm@web28104.mail.ukl.yahoo.com
Whole thread Raw
List pgsql-general
> create or replace function sum_elements(anyarray)
> returns anyelement as $$
> select sum($1[i])
>    from generate_series(array_lower($1,1),
>                                        array_upper($1,1)) g(i);
> $$ language sql immutable;


Thank you! Anyway what I was really asking was a "$" (or whatever other symbol) in place of ":" for sum, that is a
notationlike 

myarray_col[12$16]

would give the sum of all values from myarray_col[12] to myarray_col[16]

Anyway, I was reading that multidimensional arrays must have matching dimensions (that is, they can't be, for example,
[5][9]).
Is this right? Why is that?



Thank you


      Inviato da Yahoo! Mail.
La casella di posta intelligente.
http://it.docs.yahoo.com/mail/overview/index.html

pgsql-general by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: Foreign keys causing conflicts leading toserialization failures
Next
From: "Leif B. Kristensen"
Date:
Subject: Re: simple update queries take a long time - postgres 8.3.1