From: | Andrés P(dot)P(dot) <solopostgres(at)gmail(dot)com> |
---|---|
To: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Castear desde un record type a los indices de un array |
Date: | 2010-07-30 22:17:35 |
Message-ID: | AANLkTin_UN5_09emnw_wTM-ouCaXOMsyK7fpYxAaOgdn@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola
Les indico extractos de los objetos asociados a mi consulta.
tabla:
create table test_catalog.test_table (
....,
....,
test_minute_trans integer[][]
) without oids;
osea, un atributo de tipo Array de dos dimensiones..... ese atributo
contiene pares (minuto, transacciones) ..60 pares en total..
función: (Para cálculo de transacciones por minuto)
create or replace function test_catalog.fun_test_calc() returns void as $$
declare
v_record record;
begin
for v_record in select bla..bla..
extract ('minute' from test_datetime) as
trans_minute,
sum(test_value) as tot_trans
from test_catalog.tab_test_detalle
group by bla.. bla..
extract ('minute' from test_datetime)
loop
update test_catalog.test_table
set
test_minute_trans[v_record.trans_minute:v_record.trans_minute][2:2] =
'{'||v_record.tot_trans||'}'
where mas bla bla ....
end loop;
end ; $$ language plpgsql;
La función se crea sin problemas de compilación... pero al momento de
ejecutarla me arroja:
========================================================
testdb=# \i crea_fun.sql
CREATE FUNCTION
testdb=# select * from test_catalog.fun_test_calc();
ERROR: array assignment to "test_minute_trans" requires type integer[] but
expression is of type text
LINE 1: update test_catalog.test_table set test_minute_trans[ $1 : $2 ][2:2]
=...
^
HINT: You will need to rewrite or cast the expression.
QUERY: update test_catalog.test_table set test_minute_trans[ $1 : $2 ][2:2]
= '{'|| $3 ||'}' where ...........
CONTEXT: PL/pgSQL function "fun_test_calc" line 27 at SQL statement
(por si llega mal identado el signo ^ apunta a test_minute_trans)
========================================================
Me podrían ayudar a solucionar este problema.. he intentando castear , usar
to_number pero me reclama errores similares...Talvez estoy usando mal los
intentos de casteo ..
Gracias desde ya
Andrés.
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2010-07-30 22:39:07 | Re: Castear desde un record type a los indices de un array |
Previous Message | Gilberto Castillo Martínez | 2010-07-30 17:24:18 | Re: Re: [pgsql-es-ayuda] Sobre proyecto de traducción |