Ah, legal! Vlw a dica, JotaComm!
2009/8/18 JotaComm <jota.c...@gmail.com>: > > Olá, > > Você usar o GET DIAGNOSTICS com ROW_COUNT. > > Por exemplo: > > Na seção DECLARE defina uma variável. > > Por exemplo: > > DECLARE > linhas integer not null:=0; > BEGIN > ... > DELETE FROM tabela WHERE condicao; > GET DIAGNOSTICS linhas:=ROW_COUNT; > RETURN linhas; > ... > > > > 2009/8/18 Fabiano Chiqueti <chiqu...@gmail.com> >> >> Pessoal >> >> Tô usando o PostgreSQL versão 8.3.7. Como faço para colocar em uma >> variável local a quantidade de registros excluídos em um delete >> estático (não dentro de um EXECUTE) em uma função plpgsql? >> >> Algo como: >> >> CREATE OR REPLACE FUNCTION exclui_registros() RETURNS BIGINT AS >> $BODY$ >> DECLARE >> qtde_reg_excluidos BIGINT; >> BEGIN >> >> DELETE FROM <tabela_qualquer> >> WHERE <condicao> >> RETURNING COUNT(*) -- infelizmente não é possível colocar função de >> agregação na cláusula RETURNING >> INTO qtde_reg_excluidos; >> >> RETURN qtde_reg_excluidos; >> >> END; >> $BODY$ >> LANGUAGE 'plpgsql' >> >> Desde já agradeço >> >> Chiqueti >> _______________________________________________ >> pgbr-geral mailing list >> pgbr-geral@listas.postgresql.org.br >> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral > > > []s > -- > JotaComm > http://jotacomm.wordpress.com > http://www.dextra.com.br/postgres > > _______________________________________________ > pgbr-geral mailing list > pgbr-geral@listas.postgresql.org.br > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral > > _______________________________________________ pgbr-geral mailing list pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral