sexta-feira, 1 de fevereiro de 2013
Firebird: Exibir total de registros de todas as tabelas
CREATE PROCEDURE SOMAREGISTROS
RETURNS (
TABELA VARCHAR (31),
QTD_REG INTEGER)
AS declare variable comando varchar(100);
declare variable qtdtot integer;
declare variable qtdtab integer;
begin
qtdtot = 0;
qtdtab = 0;
for select rdb$relation_name
from rdb$relations
where rdb$flags = 1 and rdb$view_blr is null
order by 1
into :tabela do
begin
qtdtab = qtdtab + 1;
comando = 'select count(*) from ' || :tabela;
execute statement :comando into :qtd_reg;
qtdtot = :qtdtot + :qtd_reg;
suspend;
end
tabela = :qtdtab || ' Tabelas - Total:';
qtd_reg = :qtdtot;
suspend;
end
Assinar:
Postar comentários (Atom)
Parabéns! Me ajudou muito!!! Vinícius - ZWK Software BH/MG
ResponderExcluir