Em 9 de março de 2010 19:29, Tiago Kepe <[email protected]> escreveu:
> Oi pessoal,
>
> Preciso de ajuda, procurei na net e post antigos, mas não encontrei nada que
> me ajudasse.
>
> Preciso passar um array como parâmetro para uma função e ela me retornará o
> mesmo array alterado.
> Vi algumas explicações na net e a função atualmente está assim:
>
> CREATE OR REPLACE FUNCTION teste_array(integer[]) RETURNS integer[] AS $$
> DECLARE
> array integer[];
> BEGIN
> array := $1;
> FOR i IN 1..10 LOOP
> array[i] := i+9;
> END LOOP;
> RETURN array;
> END;
> $$ LANGUAGE plpgsql;
>
> Porém está retornando o seguinte erro:
>
> psql:teste.sql:14: ERRO: não pode mudar o tipo de retorno da função
> existente
> HINT: Primeiro utilize DROP FUNCTION.
>
> P.S. Já coloquei um DROP FUNCTION teste_array() no começo da função, não
> acho necessário pq tem um REPLACE, mas em todo caso.
>
Tente:
CREATE OR REPLACE FUNCTION teste_array(inout array integer[]) AS $$
BEGIN
FOR i IN 1..array_upper(array, 1) LOOP
array[i] := i+9;
END LOOP;
RETURN;
END;
$$ LANGUAGE plpgsql;
Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral