create or replace function todosexamesprontos(integer, integer) returns boolean AS $$
declare 
  total integer;
  prontos integer;
  codigofilial alias for $1;
  codigorequisicao alias for $2;
begin
    select count(exa_codigo) into total from examerequisicao where fil_codigo = codigofilial and req_codigo = codigorequisicao and exr_excluido = false;
    select count(exa_codigo) into prontos from examerequisicao where fil_codigo = codigofilial and req_codigo = codigorequisicao and exr_excluido = false 
   		                                                         and upper(exr_situacao) in (upper('C'), upper('I'), upper('E'), upper('A'));
	return total = prontos;
end;
$$ language plpgsql;

insert into atualizacoes(atu_nome) values ('v22030002_040322sql');

alter table examesalvaro alter alv_codexame type varchar(20);


insert into atualizacoes(atu_nome) values ('v22030001_240222sql');