Esta é a primeira vez que vejo um erro destes:
Erro: não foi possível acessar o status da transação 2662172 DETALHE:
Não foi possível abrir o arquivo "pg_subtrans/0028"
Este erro aconteceu no update de uma tabela que dispara um gatilho que
modifica outras tabelas conforme código abaixo. A mesma operação foi
tentada novamente segundos depois e o erro não se repetiu mais...
Consultei também o espaço em disco e está 20% de uso.
CREATE OR REPLACE FUNCTION uva.tac_regaula_calcres()
RETURNS trigger AS
$BODY$
DECLARE
reghis RECORD;
BEGIN
IF TG_OP='INSERT' THEN
UPDATE tac_disciplina_turma SET auddtu=(SELECT
coalesce(count(codrea),0) FROM tac_regaula WHERE dturea=new.dturea and
(tiprea='A' OR tiprea='N')) WHERE coddtu=new.dturea;
FOR reghis IN SELECT * FROM tac_historico LEFT JOIN tac_matricula
ON mathis=codmat WHERE dtuhis=new.dturea and ((stamat<>'Ativo' and
stamat<>'Concluído') or datmat>new.datrea) LOOP
INSERT INTO tac_regfrequencia (hisref,rearef,freref) values
(reghis.codhis,new.codrea,'F');
-- UPDATE tac_historico SET falhis=(SELECT
coalesce(count(codrea),0) FROM tac_regfrequencia LEFT JOIN tac_regaula
ON (rearef=codrea and dturea=dtuhis) WHERE hisref=codhis and freref='F'
and (tiprea='A' OR tiprea='N')) WHERE codhis=reghis.codhis;
END LOOP;
return new;
ELSEIF TG_OP='UPDATE' THEN
UPDATE tac_disciplina_turma SET auddtu=(SELECT
coalesce(count(codrea),0) FROM tac_regaula WHERE dturea=new.dturea and
(tiprea='A' OR tiprea='N')) WHERE coddtu=new.dturea;
FOR reghis IN SELECT * FROM tac_historico WHERE dtuhis=new.dturea
LOOP
UPDATE tac_historico SET falhis=(SELECT
coalesce(count(codrea),0) FROM tac_regfrequencia LEFT JOIN tac_regaula
ON (rearef=codrea and dturea=dtuhis) WHERE hisref=codhis and freref='F'
and (tiprea='A' OR tiprea='N')) WHERE codhis=reghis.codhis;
END LOOP;
return new;
ELSE
UPDATE tac_disciplina_turma SET auddtu=(SELECT
coalesce(count(codrea),0) FROM tac_regaula WHERE dturea=old.dturea and
(tiprea='A' OR tiprea='N')) WHERE coddtu=old.dturea;
FOR reghis IN SELECT * FROM tac_historico WHERE dtuhis=old.dturea
LOOP
UPDATE tac_historico SET falhis=(SELECT
coalesce(count(codrea),0) FROM tac_regfrequencia LEFT JOIN tac_regaula
ON (rearef=codrea and dturea=dtuhis) WHERE hisref=codhis and freref='F'
and (tiprea='A' OR tiprea='N')) WHERE codhis=reghis.codhis;
END LOOP;
return old;
END IF;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
--
.~. Prof. Cleverson B. Klettenberg
/ v \ [email protected]
/( )\
^^-^^ Seja Livre!
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral