Em 27/10/08, Thiago<[EMAIL PROTECTED]> escreveu:
> Jota, desculpe a minha ignorancia mas não estou entendendo, como faço
> para armazenar os valores na matriz e depois recuperar, no exemplo que
> me deu está apenas definindo o tamanho da matriz, pelo menos foi o que
> eu entendi ... se tiver como me fazer um exemplo muito simples que faça
> o seguinte rode uma matriz de 4x4 e armazene 1 x o contador. Pois do
> jeito que me explicou não entendi muito bem, como vou fazer para
> armazenar nas posições do vetor.
>
Veja se este exemplo esclarece suas dúvidas:
CREATE OR REPLACE FUNCTION testfunc1() RETURNS void AS $$
DECLARE
i int;
j int;
myArray int[][] := '{}';
auxArray int[] := '{}';
BEGIN
FOR i IN 1..4 LOOP
RAISE NOTICE 'array_dims(myArray): %', array_dims(myArray);
auxArray := '{}';
FOR j IN 1..3 LOOP
RAISE NOTICE '% % %', i, j,auxArray;
auxArray := array_append(auxArray, j);
END LOOP;
RAISE NOTICE 'auxArray: %', auxArray;
myArray := array_cat(myArray, ARRAY[auxArray]);
END LOOP;
RAISE NOTICE 'myArray: %', myArray;
RETURN;
END
$$ LANGUAGE plpgsql;
Osvaldo
PS.: A outra opção é inicializar o array.
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral