<?xml version="1.0" standalone="yes"?>
  <DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="pro_key" fieldtype="string.uni" WIDTH="128">
<PARAM Name="ORIGIN" Value="pro_key" Roundtrip="True"/>
</FIELD>
<FIELD attrname="procedure_source" fieldtype="bin.hex" SUBTYPE="WideText">
<PARAM Name="PROVFLAGS" Value="1" Type="i4" Roundtrip="True"/>
<PARAM Name="ORIGIN" Value="procedure_source" Roundtrip="True"/>
</FIELD>
</FIELDS>
<PARAMS DEFAULT_ORDER="1"/>
</METADATA>
<ROWDATA>
<ROW pro_key="afastamentoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.afastamentoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;AFASTAMENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AFASTAMENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, dataafast, seq, qtdehorafalta, horaafast, numerobeneficio, codigosit, diaslicmedica, datatermino, horatermino, dataprevtermino, perdevaletransp, qtdevaletransp, dataparto, perdedsr, perdeferias, exameretorno, observ, origemdado, perde13, codigositprorrogalicmat, tipoprorrog, diasprorrogcontrexp, tipoacidentetransito, afastamentodecorrentemotant, codigocid, cnpjcessao, codigoprocessojudadm, codigosind, onuscessao, razaosocialcessao, tipoalteracaoesocial, onusmandatosindical, origemretificacao, enviouafastamentoesocial, codigocorpoclinico, statusenvioesocial, datahoralcto, enviardataterminoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.dataafast, NEW.seq, NEW.qtdehorafalta, NEW.horaafast, NEW.numerobeneficio, NEW.codigosit, NEW.diaslicmedica, NEW.datatermino, NEW.horatermino, NEW.dataprevtermino, NEW.perdevaletransp, NEW.qtdevaletransp, NEW.dataparto, NEW.perdedsr, NEW.perdeferias, NEW.exameretorno, NEW.observ, NEW.origemdado, NEW.perde13, NEW.codigositprorrogalicmat, NEW.tipoprorrog, NEW.diasprorrogcontrexp, NEW.tipoacidentetransito, NEW.afastamentodecorrentemotant, NEW.codigocid, NEW.cnpjcessao, NEW.codigoprocessojudadm, NEW.codigosind, NEW.onuscessao, NEW.razaosocialcessao, NEW.tipoalteracaoesocial, NEW.onusmandatosindical, NEW.origemretificacao, NEW.enviouafastamentoesocial, NEW.codigocorpoclinico, NEW.statusenvioesocial, NEW.datahoralcto, NEW.enviardataterminoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="afastamentoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.afastamentoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;AFASTAMENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AFASTAMENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, dataafast, seq, qtdehorafalta, horaafast, numerobeneficio, codigosit, diaslicmedica, datatermino, horatermino, dataprevtermino, perdevaletransp, qtdevaletransp, dataparto, perdedsr, perdeferias, exameretorno, observ, origemdado, perde13, codigositprorrogalicmat, tipoprorrog, diasprorrogcontrexp, tipoacidentetransito, afastamentodecorrentemotant, codigocid, cnpjcessao, codigoprocessojudadm, codigosind, onuscessao, razaosocialcessao, tipoalteracaoesocial, onusmandatosindical, origemretificacao, enviouafastamentoesocial, codigocorpoclinico, statusenvioesocial, datahoralcto, enviardataterminoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.dataafast, OLD.seq, OLD.qtdehorafalta, OLD.horaafast, OLD.numerobeneficio, OLD.codigosit, OLD.diaslicmedica, OLD.datatermino, OLD.horatermino, OLD.dataprevtermino, OLD.perdevaletransp, OLD.qtdevaletransp, OLD.dataparto, OLD.perdedsr, OLD.perdeferias, OLD.exameretorno, OLD.observ, OLD.origemdado, OLD.perde13, OLD.codigositprorrogalicmat, OLD.tipoprorrog, OLD.diasprorrogcontrexp, OLD.tipoacidentetransito, OLD.afastamentodecorrentemotant, OLD.codigocid, OLD.cnpjcessao, OLD.codigoprocessojudadm, OLD.codigosind, OLD.onuscessao, OLD.razaosocialcessao, OLD.tipoalteracaoesocial, OLD.onusmandatosindical, OLD.origemretificacao, OLD.enviouafastamentoesocial, OLD.codigocorpoclinico, OLD.statusenvioesocial, OLD.datahoralcto, OLD.enviardataterminoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;AFASTAMENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AFASTAMENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, dataafast, seq, qtdehorafalta, horaafast, numerobeneficio, codigosit, diaslicmedica, datatermino, horatermino, dataprevtermino, perdevaletransp, qtdevaletransp, dataparto, perdedsr, perdeferias, exameretorno, observ, origemdado, perde13, codigositprorrogalicmat, tipoprorrog, diasprorrogcontrexp, tipoacidentetransito, afastamentodecorrentemotant, codigocid, cnpjcessao, codigoprocessojudadm, codigosind, onuscessao, razaosocialcessao, tipoalteracaoesocial, onusmandatosindical, origemretificacao, enviouafastamentoesocial, codigocorpoclinico, statusenvioesocial, datahoralcto, enviardataterminoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.dataafast, NEW.seq, NEW.qtdehorafalta, NEW.horaafast, NEW.numerobeneficio, NEW.codigosit, NEW.diaslicmedica, NEW.datatermino, NEW.horatermino, NEW.dataprevtermino, NEW.perdevaletransp, NEW.qtdevaletransp, NEW.dataparto, NEW.perdedsr, NEW.perdeferias, NEW.exameretorno, NEW.observ, NEW.origemdado, NEW.perde13, NEW.codigositprorrogalicmat, NEW.tipoprorrog, NEW.diasprorrogcontrexp, NEW.tipoacidentetransito, NEW.afastamentodecorrentemotant, NEW.codigocid, NEW.cnpjcessao, NEW.codigoprocessojudadm, NEW.codigosind, NEW.onuscessao, NEW.razaosocialcessao, NEW.tipoalteracaoesocial, NEW.onusmandatosindical, NEW.origemretificacao, NEW.enviouafastamentoesocial, NEW.codigocorpoclinico, NEW.statusenvioesocial, NEW.datahoralcto, NEW.enviardataterminoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="afastamentobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.afastamentobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;AFASTAMENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AFASTAMENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, dataafast, seq, qtdehorafalta, horaafast, numerobeneficio, codigosit, diaslicmedica, datatermino, horatermino, dataprevtermino, perdevaletransp, qtdevaletransp, dataparto, perdedsr, perdeferias, exameretorno, observ, origemdado, perde13, codigositprorrogalicmat, tipoprorrog, diasprorrogcontrexp, tipoacidentetransito, afastamentodecorrentemotant, codigocid, cnpjcessao, codigoprocessojudadm, codigosind, onuscessao, razaosocialcessao, tipoalteracaoesocial, onusmandatosindical, origemretificacao, enviouafastamentoesocial, codigocorpoclinico, statusenvioesocial, datahoralcto, enviardataterminoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.dataafast, OLD.seq, OLD.qtdehorafalta, OLD.horaafast, OLD.numerobeneficio, OLD.codigosit, OLD.diaslicmedica, OLD.datatermino, OLD.horatermino, OLD.dataprevtermino, OLD.perdevaletransp, OLD.qtdevaletransp, OLD.dataparto, OLD.perdedsr, OLD.perdeferias, OLD.exameretorno, OLD.observ, OLD.origemdado, OLD.perde13, OLD.codigositprorrogalicmat, OLD.tipoprorrog, OLD.diasprorrogcontrexp, OLD.tipoacidentetransito, OLD.afastamentodecorrentemotant, OLD.codigocid, OLD.cnpjcessao, OLD.codigoprocessojudadm, OLD.codigosind, OLD.onuscessao, OLD.razaosocialcessao, OLD.tipoalteracaoesocial, OLD.onusmandatosindical, OLD.origemretificacao, OLD.enviouafastamentoesocial, OLD.codigocorpoclinico, OLD.statusenvioesocial, OLD.datahoralcto, OLD.enviardataterminoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="ambientetrabaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.ambientetrabaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;AMBIENTETRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AMBIENTETRABHS(SEQHISTORICO, OPERACAO, codigoambientetrab, descrambientetrab, nomeambientetrab, codigoempresa) &#013;&#010;  VALUES (GEN, 1, NEW.codigoambientetrab, NEW.descrambientetrab, NEW.nomeambientetrab, NEW.codigoempresa); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="ambientetrabauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.ambientetrabauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;AMBIENTETRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AMBIENTETRABHS(SEQHISTORICO, OPERACAO, codigoambientetrab, descrambientetrab, nomeambientetrab, codigoempresa) &#013;&#010;  VALUES (GEN, 2, OLD.codigoambientetrab, OLD.descrambientetrab, OLD.nomeambientetrab, OLD.codigoempresa); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;AMBIENTETRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AMBIENTETRABHS(SEQHISTORICO, OPERACAO, codigoambientetrab, descrambientetrab, nomeambientetrab, codigoempresa) &#013;&#010;  VALUES (GEN, 3, NEW.codigoambientetrab, NEW.descrambientetrab, NEW.nomeambientetrab, NEW.codigoempresa); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="ambientetrabbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.ambientetrabbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;AMBIENTETRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO AMBIENTETRABHS(SEQHISTORICO, OPERACAO, codigoambientetrab, descrambientetrab, nomeambientetrab, codigoempresa) &#013;&#010;  VALUES (GEN, 4, OLD.codigoambientetrab, OLD.descrambientetrab, OLD.nomeambientetrab, OLD.codigoempresa); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="ambientetrabfatorriscoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.ambientetrabfatorriscoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#010;DECLARE GEN INTEGER; &#010;BEGIN &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;AMBIENTETRABFATORRISCOHS&apos;); &#010;&#010;  INSERT INTO AMBIENTETRABFATORRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoambientetrab, datainicial, codigofatorrisco, tipoalteracaoesocial) &#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoambientetrab, NEW.datainicial, NEW.codigofatorrisco, NEW.tipoalteracaoesocial); &#010;&#010;RETURN NEW; &#010;END &#010;$function$&#010;"/>
<ROW pro_key="ambientetrabfatorriscoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.ambientetrabfatorriscoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#010;DECLARE GEN INTEGER; &#010;BEGIN &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;AMBIENTETRABFATORRISCOHS&apos;); &#010;&#010;  INSERT INTO AMBIENTETRABFATORRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoambientetrab, datainicial, codigofatorrisco, tipoalteracaoesocial) &#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoambientetrab, OLD.datainicial, OLD.codigofatorrisco, OLD.tipoalteracaoesocial); &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;AMBIENTETRABFATORRISCOHS&apos;); &#010;&#010;  INSERT INTO AMBIENTETRABFATORRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoambientetrab, datainicial, codigofatorrisco, tipoalteracaoesocial) &#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoambientetrab, NEW.datainicial, NEW.codigofatorrisco, NEW.tipoalteracaoesocial); &#010;&#010;RETURN NEW; END &#010;$function$&#010;"/>
<ROW pro_key="ambientetrabfatorriscobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.ambientetrabfatorriscobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#010;DECLARE GEN INTEGER; &#010;BEGIN &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;AMBIENTETRABFATORRISCOHS&apos;); &#010;&#010;  INSERT INTO AMBIENTETRABFATORRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoambientetrab, datainicial, codigofatorrisco, tipoalteracaoesocial) &#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoambientetrab, OLD.datainicial, OLD.codigofatorrisco, OLD.tipoalteracaoesocial); &#010;&#010;RETURN OLD; END &#010;$function$&#010;"/>
<ROW pro_key="calculoprofbif" procedure_source="CREATE OR REPLACE FUNCTION public.calculoprofbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i NUMERIC(14,0);&#013;&#010;BEGIN&#013;&#010;  IF new.SEQ IS NULL THEN&#013;&#010;    new.SEQ = nextval(&apos;gen_seqcalculoprof&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_seqcalculoprof&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_seqcalculoprof;&#013;&#010;END;&#013;&#010;WHILE (NEW.SEQ &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_seqcalculoprof&apos;) INTO i;&#013;&#010;END LOOP; &#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="campovaloresiss_bif" procedure_source="CREATE OR REPLACE FUNCTION public.campovaloresiss_bif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;tmp DECIMAL(18,0); &#013;&#010;BEGIN &#013;&#010;  IF (NEW.CODIGOVALOR IS NULL) THEN &#013;&#010;    NEW.CODIGOVALOR = nextval(&apos;gen_campovaloresiss&apos;); &#013;&#010;  ELSE &#013;&#010;BEGIN &#013;&#010;SELECT CURRVAL(&apos;gen_campovaloresiss&apos;) INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO tmp FROM gen_campovaloresiss;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOVALOR &gt; tmp) LOOP &#013;&#010;SELECT nextval(&apos;gen_campovaloresiss&apos;) INTO tmp;&#013;&#010;END LOOP; &#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOHS(SEQHISTORICO, OPERACAO, codigocargo, datainicial, descrcargo, cbo, cbo94, codigoselecao, cargopublico, funcaoppp, tipoalteracaoesocial, acumulacargo, codigocargodomestico, contagemtempo, dedicexc) &#013;&#010;  VALUES (GEN, 1, NEW.codigocargo, NEW.datainicial, NEW.descrcargo, NEW.cbo, NEW.cbo94, NEW.codigoselecao, NEW.cargopublico, NEW.funcaoppp, NEW.tipoalteracaoesocial, NEW.acumulacargo, NEW.codigocargodomestico, NEW.contagemtempo, NEW.dedicexc); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoativtrabaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoativtrabaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOATIVTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOATIVTRABHS(SEQHISTORICO, OPERACAO, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 1, NEW.codigocargo, NEW.codigoativtrab); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoativtrabauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoativtrabauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOATIVTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOATIVTRABHS(SEQHISTORICO, OPERACAO, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 2, OLD.codigocargo, OLD.codigoativtrab); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOATIVTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOATIVTRABHS(SEQHISTORICO, OPERACAO, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 3, NEW.codigocargo, NEW.codigoativtrab); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoativtrabbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoativtrabbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOATIVTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOATIVTRABHS(SEQHISTORICO, OPERACAO, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 4, OLD.codigocargo, OLD.codigoativtrab); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOHS(SEQHISTORICO, OPERACAO, codigocargo, datainicial, descrcargo, cbo, cbo94, codigoselecao, cargopublico, funcaoppp, tipoalteracaoesocial, acumulacargo, codigocargodomestico, contagemtempo, dedicexc) &#013;&#010;  VALUES (GEN, 2, OLD.codigocargo, OLD.datainicial, OLD.descrcargo, OLD.cbo, OLD.cbo94, OLD.codigoselecao, OLD.cargopublico, OLD.funcaoppp, OLD.tipoalteracaoesocial, OLD.acumulacargo, OLD.codigocargodomestico, OLD.contagemtempo, OLD.dedicexc); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOHS(SEQHISTORICO, OPERACAO, codigocargo, datainicial, descrcargo, cbo, cbo94, codigoselecao, cargopublico, funcaoppp, tipoalteracaoesocial, acumulacargo, codigocargodomestico, contagemtempo, dedicexc) &#013;&#010;  VALUES (GEN, 3, NEW.codigocargo, NEW.datainicial, NEW.descrcargo, NEW.cbo, NEW.cbo94, NEW.codigoselecao, NEW.cargopublico, NEW.funcaoppp, NEW.tipoalteracaoesocial, NEW.acumulacargo, NEW.codigocargodomestico, NEW.contagemtempo, NEW.dedicexc); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOHS(SEQHISTORICO, OPERACAO, codigocargo, datainicial, descrcargo, cbo, cbo94, codigoselecao, cargopublico, funcaoppp, tipoalteracaoesocial, acumulacargo, codigocargodomestico, contagemtempo, dedicexc) &#013;&#010;  VALUES (GEN, 4, OLD.codigocargo, OLD.datainicial, OLD.descrcargo, OLD.cbo, OLD.cbo94, OLD.codigoselecao, OLD.cargopublico, OLD.funcaoppp, OLD.tipoalteracaoesocial, OLD.acumulacargo, OLD.codigocargodomestico, OLD.contagemtempo, OLD.dedicexc); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoempresaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoempresaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CARGOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigocargorelat, codigocargo, datainicial, status) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigocargorelat, NEW.codigocargo, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoempresaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoempresaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CARGOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigocargorelat, codigocargo, datainicial, status) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigocargorelat, OLD.codigocargo, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CARGOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigocargorelat, codigocargo, datainicial, status) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigocargorelat, NEW.codigocargo, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoempresabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoempresabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CARGOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigocargorelat, codigocargo, datainicial, status) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigocargorelat, OLD.codigocargo, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoleiaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoleiaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOLEIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOLEIHS(SEQHISTORICO, OPERACAO, codigocargo, numerolei, datalei, sitgerada) &#013;&#010;  VALUES (GEN, 1, NEW.codigocargo, NEW.numerolei, NEW.datalei, NEW.sitgerada); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoleiauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoleiauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOLEIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOLEIHS(SEQHISTORICO, OPERACAO, codigocargo, numerolei, datalei, sitgerada) &#013;&#010;  VALUES (GEN, 2, OLD.codigocargo, OLD.numerolei, OLD.datalei, OLD.sitgerada); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOLEIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOLEIHS(SEQHISTORICO, OPERACAO, codigocargo, numerolei, datalei, sitgerada) &#013;&#010;  VALUES (GEN, 3, NEW.codigocargo, NEW.numerolei, NEW.datalei, NEW.sitgerada); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cargoleibdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cargoleibdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CARGOLEIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CARGOLEIHS(SEQHISTORICO, OPERACAO, codigocargo, numerolei, datalei, sitgerada) &#013;&#010;  VALUES (GEN, 4, OLD.codigocargo, OLD.numerolei, OLD.datalei, OLD.sitgerada); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="carregarmoedafuncional" procedure_source="CREATE OR REPLACE FUNCTION public.carregarmoedafuncional(pcodigoempresa smallint, pcodigoestab smallint, pdatamoeda date, OUT codigomoeda smallint)&#010; RETURNS smallint&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;BEGIN &#013;&#010;  SELECT O.CodigoMoeda &#013;&#010;  FROM OPCAOMOEDAFUNCIONAL O &#013;&#010;  WHERE O.CODIGOEMPRESA = pCodigoEmpresa &#013;&#010;  AND O.CODIGOESTAB = pCodigoEstab &#013;&#010;  AND O.DATAINICIAL &lt;= pDataMoeda &#013;&#010;  AND (O.DATAFINAL &gt;= pDataMoeda OR O.DATAFINAL IS NULL) &#013;&#010;  INTO CodigoMoeda; &#013;&#010; &#013;&#010;  IF (CodigoMoeda IS NULL) THEN &#013;&#010;    SELECT O.CodigoMoeda &#013;&#010;    FROM OPCAOMOEDAFUNCIONAL O &#013;&#010;    WHERE O.CODIGOEMPRESA = pCodigoEmpresa &#013;&#010;    AND O.CODIGOESTAB = 1/*Matriz*/ &#013;&#010;    AND O.DATAINICIAL &lt;= pDataMoeda &#013;&#010;    AND (O.DATAFINAL &gt;= pDataMoeda or O.DATAFINAL IS NULL) &#013;&#010;    INTO CodigoMoeda; &#013;&#010;  END IF; &#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="cestbif" procedure_source="CREATE OR REPLACE FUNCTION public.cestbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE&#013;&#010;i INTEGER;&#013;&#010;BEGIN&#013;&#010;  IF (new.CODIGOCEST is null) THEN&#013;&#010;    new.CODIGOCEST = nextval(&apos;gen_codigocest&apos;);&#013;&#010;  ELSE&#013;&#010;    BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigocest&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_codigocest;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOCEST &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigocest&apos;) INTO i;&#013;&#010;END LOOP; &#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgempresafpaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgempresafpaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CFGEMPRESAFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGEMPRESAFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, processocontrisocialresc, folhahoradia, horasnot5230, valorarred, prazopgtomensal, vacinfreq, pgtofolhamensaladto, pgtoadmmens, formacalctrocaescalames, eventoiniesocial, pgtodemmens, sepdsrhrmensfer, sepdsrmens, pagasalfamintermitente, calculofaltas, perdedsrfaltas, utilestrutsal, codigoestrutsal, utilbeneficio, pagaferiado, utilvaletransp, utilrefeicao, utilsinchist, organograma, horacent, utilrateio, codigogrupotabelacontabil, contabiliza, codigoempctb, rateiogerencial, insssepar, escalamensalhor, codigoassiduidade, registroinformat, percpis, salfamadmdem, escalamensalprof, utilcalcprof, codigopercalculo, utilppp, gerarais, numeroconvenio, gpscompensarprim, horanormalcritrat, depend13dirfinforme, datacompensacaoterceiros, compensacaogps, competperagrupador, formageracaodarf, datainicialcalcmovusu, datafinalcalcmovusu, datainicialprovusu, datafinalprovusu, datainicialcalcvtrusu, utilobratomadortabferiado, sistemaanuidade, datafinalcalcvtrusu, codigoanuidade, separarhorasapt, separarferiasind, diversasativcnae, pagafastmensalista, prorrogalicmat, codigousuariocalculando, gerardebitofolhactr, utilfuncao, codigolayoutcontabilizacao, anuidadetemposervico, pontotoleran, pontotolerandia, pontocontrole, utilfaixaremun, utillimiteminferias, tipoalteracaoesocial, acaoimportacaozen, evespecificoesocial1299, utilcalcautomatizado, impesocial, arrendcenthora, senhafap, considerareducao13media, datacompensacaocruzada, utilizaguiarescisoriaauto, tipoenvioedoc, formageracaofgts, dataopcaoutilguiarescauto, competopcaocalcpatronal) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datainicial, NEW.processocontrisocialresc, NEW.folhahoradia, NEW.horasnot5230, NEW.valorarred, NEW.prazopgtomensal, NEW.vacinfreq, NEW.pgtofolhamensaladto, NEW.pgtoadmmens, NEW.formacalctrocaescalames, NEW.eventoiniesocial, NEW.pgtodemmens, NEW.sepdsrhrmensfer, NEW.sepdsrmens, NEW.pagasalfamintermitente, NEW.calculofaltas, NEW.perdedsrfaltas, NEW.utilestrutsal, NEW.codigoestrutsal, NEW.utilbeneficio, NEW.pagaferiado, NEW.utilvaletransp, NEW.utilrefeicao, NEW.utilsinchist, NEW.organograma, NEW.horacent, NEW.utilrateio, NEW.codigogrupotabelacontabil, NEW.contabiliza, NEW.codigoempctb, NEW.rateiogerencial, NEW.insssepar, NEW.escalamensalhor, NEW.codigoassiduidade, NEW.registroinformat, NEW.percpis, NEW.salfamadmdem, NEW.escalamensalprof, NEW.utilcalcprof, NEW.codigopercalculo, NEW.utilppp, NEW.gerarais, NEW.numeroconvenio, NEW.gpscompensarprim, NEW.horanormalcritrat, NEW.depend13dirfinforme, NEW.datacompensacaoterceiros, NEW.compensacaogps, NEW.competperagrupador, NEW.formageracaodarf, NEW.datainicialcalcmovusu, NEW.datafinalcalcmovusu, NEW.datainicialprovusu, NEW.datafinalprovusu, NEW.datainicialcalcvtrusu, NEW.utilobratomadortabferiado, NEW.sistemaanuidade, NEW.datafinalcalcvtrusu, NEW.codigoanuidade, NEW.separarhorasapt, NEW.separarferiasind, NEW.diversasativcnae, NEW.pagafastmensalista, NEW.prorrogalicmat, NEW.codigousuariocalculando, NEW.gerardebitofolhactr, NEW.utilfuncao, NEW.codigolayoutcontabilizacao, NEW.anuidadetemposervico, NEW.pontotoleran, NEW.pontotolerandia, NEW.pontocontrole, NEW.utilfaixaremun, NEW.utillimiteminferias, NEW.tipoalteracaoesocial, NEW.acaoimportacaozen, NEW.evespecificoesocial1299, NEW.utilcalcautomatizado, NEW.impesocial, NEW.arrendcenthora, NEW.senhafap, NEW.considerareducao13media, NEW.datacompensacaocruzada, NEW.utilizaguiarescisoriaauto, NEW.tipoenvioedoc, NEW.formageracaofgts, NEW.dataopcaoutilguiarescauto, NEW.competopcaocalcpatronal); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgempresafpaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgempresafpaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CFGEMPRESAFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGEMPRESAFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, processocontrisocialresc, folhahoradia, horasnot5230, valorarred, prazopgtomensal, vacinfreq, pgtofolhamensaladto, pgtoadmmens, formacalctrocaescalames, eventoiniesocial, pgtodemmens, sepdsrhrmensfer, sepdsrmens, pagasalfamintermitente, calculofaltas, perdedsrfaltas, utilestrutsal, codigoestrutsal, utilbeneficio, pagaferiado, utilvaletransp, utilrefeicao, utilsinchist, organograma, horacent, utilrateio, codigogrupotabelacontabil, contabiliza, codigoempctb, rateiogerencial, insssepar, escalamensalhor, codigoassiduidade, registroinformat, percpis, salfamadmdem, escalamensalprof, utilcalcprof, codigopercalculo, utilppp, gerarais, numeroconvenio, gpscompensarprim, horanormalcritrat, depend13dirfinforme, datacompensacaoterceiros, compensacaogps, competperagrupador, formageracaodarf, datainicialcalcmovusu, datafinalcalcmovusu, datainicialprovusu, datafinalprovusu, datainicialcalcvtrusu, utilobratomadortabferiado, sistemaanuidade, datafinalcalcvtrusu, codigoanuidade, separarhorasapt, separarferiasind, diversasativcnae, pagafastmensalista, prorrogalicmat, codigousuariocalculando, gerardebitofolhactr, utilfuncao, codigolayoutcontabilizacao, anuidadetemposervico, pontotoleran, pontotolerandia, pontocontrole, utilfaixaremun, utillimiteminferias, tipoalteracaoesocial, acaoimportacaozen, evespecificoesocial1299, utilcalcautomatizado, impesocial, arrendcenthora, senhafap, considerareducao13media, datacompensacaocruzada, utilizaguiarescisoriaauto, tipoenvioedoc, formageracaofgts, dataopcaoutilguiarescauto, competopcaocalcpatronal) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datainicial, OLD.processocontrisocialresc, OLD.folhahoradia, OLD.horasnot5230, OLD.valorarred, OLD.prazopgtomensal, OLD.vacinfreq, OLD.pgtofolhamensaladto, OLD.pgtoadmmens, OLD.formacalctrocaescalames, OLD.eventoiniesocial, OLD.pgtodemmens, OLD.sepdsrhrmensfer, OLD.sepdsrmens, OLD.pagasalfamintermitente, OLD.calculofaltas, OLD.perdedsrfaltas, OLD.utilestrutsal, OLD.codigoestrutsal, OLD.utilbeneficio, OLD.pagaferiado, OLD.utilvaletransp, OLD.utilrefeicao, OLD.utilsinchist, OLD.organograma, OLD.horacent, OLD.utilrateio, OLD.codigogrupotabelacontabil, OLD.contabiliza, OLD.codigoempctb, OLD.rateiogerencial, OLD.insssepar, OLD.escalamensalhor, OLD.codigoassiduidade, OLD.registroinformat, OLD.percpis, OLD.salfamadmdem, OLD.escalamensalprof, OLD.utilcalcprof, OLD.codigopercalculo, OLD.utilppp, OLD.gerarais, OLD.numeroconvenio, OLD.gpscompensarprim, OLD.horanormalcritrat, OLD.depend13dirfinforme, OLD.datacompensacaoterceiros, OLD.compensacaogps, OLD.competperagrupador, OLD.formageracaodarf, OLD.datainicialcalcmovusu, OLD.datafinalcalcmovusu, OLD.datainicialprovusu, OLD.datafinalprovusu, OLD.datainicialcalcvtrusu, OLD.utilobratomadortabferiado, OLD.sistemaanuidade, OLD.datafinalcalcvtrusu, OLD.codigoanuidade, OLD.separarhorasapt, OLD.separarferiasind, OLD.diversasativcnae, OLD.pagafastmensalista, OLD.prorrogalicmat, OLD.codigousuariocalculando, OLD.gerardebitofolhactr, OLD.utilfuncao, OLD.codigolayoutcontabilizacao, OLD.anuidadetemposervico, OLD.pontotoleran, OLD.pontotolerandia, OLD.pontocontrole, OLD.utilfaixaremun, OLD.utillimiteminferias, OLD.tipoalteracaoesocial, OLD.acaoimportacaozen, OLD.evespecificoesocial1299, OLD.utilcalcautomatizado, OLD.impesocial, OLD.arrendcenthora, OLD.senhafap, OLD.considerareducao13media, OLD.datacompensacaocruzada, OLD.utilizaguiarescisoriaauto, OLD.tipoenvioedoc, OLD.formageracaofgts, OLD.dataopcaoutilguiarescauto, OLD.competopcaocalcpatronal); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CFGEMPRESAFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGEMPRESAFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, processocontrisocialresc, folhahoradia, horasnot5230, valorarred, prazopgtomensal, vacinfreq, pgtofolhamensaladto, pgtoadmmens, formacalctrocaescalames, eventoiniesocial, pgtodemmens, sepdsrhrmensfer, sepdsrmens, pagasalfamintermitente, calculofaltas, perdedsrfaltas, utilestrutsal, codigoestrutsal, utilbeneficio, pagaferiado, utilvaletransp, utilrefeicao, utilsinchist, organograma, horacent, utilrateio, codigogrupotabelacontabil, contabiliza, codigoempctb, rateiogerencial, insssepar, escalamensalhor, codigoassiduidade, registroinformat, percpis, salfamadmdem, escalamensalprof, utilcalcprof, codigopercalculo, utilppp, gerarais, numeroconvenio, gpscompensarprim, horanormalcritrat, depend13dirfinforme, datacompensacaoterceiros, compensacaogps, competperagrupador, formageracaodarf, datainicialcalcmovusu, datafinalcalcmovusu, datainicialprovusu, datafinalprovusu, datainicialcalcvtrusu, utilobratomadortabferiado, sistemaanuidade, datafinalcalcvtrusu, codigoanuidade, separarhorasapt, separarferiasind, diversasativcnae, pagafastmensalista, prorrogalicmat, codigousuariocalculando, gerardebitofolhactr, utilfuncao, codigolayoutcontabilizacao, anuidadetemposervico, pontotoleran, pontotolerandia, pontocontrole, utilfaixaremun, utillimiteminferias, tipoalteracaoesocial, acaoimportacaozen, evespecificoesocial1299, utilcalcautomatizado, impesocial, arrendcenthora, senhafap, considerareducao13media, datacompensacaocruzada, utilizaguiarescisoriaauto, tipoenvioedoc, formageracaofgts, dataopcaoutilguiarescauto, competopcaocalcpatronal) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datainicial, NEW.processocontrisocialresc, NEW.folhahoradia, NEW.horasnot5230, NEW.valorarred, NEW.prazopgtomensal, NEW.vacinfreq, NEW.pgtofolhamensaladto, NEW.pgtoadmmens, NEW.formacalctrocaescalames, NEW.eventoiniesocial, NEW.pgtodemmens, NEW.sepdsrhrmensfer, NEW.sepdsrmens, NEW.pagasalfamintermitente, NEW.calculofaltas, NEW.perdedsrfaltas, NEW.utilestrutsal, NEW.codigoestrutsal, NEW.utilbeneficio, NEW.pagaferiado, NEW.utilvaletransp, NEW.utilrefeicao, NEW.utilsinchist, NEW.organograma, NEW.horacent, NEW.utilrateio, NEW.codigogrupotabelacontabil, NEW.contabiliza, NEW.codigoempctb, NEW.rateiogerencial, NEW.insssepar, NEW.escalamensalhor, NEW.codigoassiduidade, NEW.registroinformat, NEW.percpis, NEW.salfamadmdem, NEW.escalamensalprof, NEW.utilcalcprof, NEW.codigopercalculo, NEW.utilppp, NEW.gerarais, NEW.numeroconvenio, NEW.gpscompensarprim, NEW.horanormalcritrat, NEW.depend13dirfinforme, NEW.datacompensacaoterceiros, NEW.compensacaogps, NEW.competperagrupador, NEW.formageracaodarf, NEW.datainicialcalcmovusu, NEW.datafinalcalcmovusu, NEW.datainicialprovusu, NEW.datafinalprovusu, NEW.datainicialcalcvtrusu, NEW.utilobratomadortabferiado, NEW.sistemaanuidade, NEW.datafinalcalcvtrusu, NEW.codigoanuidade, NEW.separarhorasapt, NEW.separarferiasind, NEW.diversasativcnae, NEW.pagafastmensalista, NEW.prorrogalicmat, NEW.codigousuariocalculando, NEW.gerardebitofolhactr, NEW.utilfuncao, NEW.codigolayoutcontabilizacao, NEW.anuidadetemposervico, NEW.pontotoleran, NEW.pontotolerandia, NEW.pontocontrole, NEW.utilfaixaremun, NEW.utillimiteminferias, NEW.tipoalteracaoesocial, NEW.acaoimportacaozen, NEW.evespecificoesocial1299, NEW.utilcalcautomatizado, NEW.impesocial, NEW.arrendcenthora, NEW.senhafap, NEW.considerareducao13media, NEW.datacompensacaocruzada, NEW.utilizaguiarescisoriaauto, NEW.tipoenvioedoc, NEW.formageracaofgts, NEW.dataopcaoutilguiarescauto, NEW.competopcaocalcpatronal); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgempresafpabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgempresafpabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CFGEMPRESAFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGEMPRESAFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, processocontrisocialresc, folhahoradia, horasnot5230, valorarred, prazopgtomensal, vacinfreq, pgtofolhamensaladto, pgtoadmmens, formacalctrocaescalames, eventoiniesocial, pgtodemmens, sepdsrhrmensfer, sepdsrmens, pagasalfamintermitente, calculofaltas, perdedsrfaltas, utilestrutsal, codigoestrutsal, utilbeneficio, pagaferiado, utilvaletransp, utilrefeicao, utilsinchist, organograma, horacent, utilrateio, codigogrupotabelacontabil, contabiliza, codigoempctb, rateiogerencial, insssepar, escalamensalhor, codigoassiduidade, registroinformat, percpis, salfamadmdem, escalamensalprof, utilcalcprof, codigopercalculo, utilppp, gerarais, numeroconvenio, gpscompensarprim, horanormalcritrat, depend13dirfinforme, datacompensacaoterceiros, compensacaogps, competperagrupador, formageracaodarf, datainicialcalcmovusu, datafinalcalcmovusu, datainicialprovusu, datafinalprovusu, datainicialcalcvtrusu, utilobratomadortabferiado, sistemaanuidade, datafinalcalcvtrusu, codigoanuidade, separarhorasapt, separarferiasind, diversasativcnae, pagafastmensalista, prorrogalicmat, codigousuariocalculando, gerardebitofolhactr, utilfuncao, codigolayoutcontabilizacao, anuidadetemposervico, pontotoleran, pontotolerandia, pontocontrole, utilfaixaremun, utillimiteminferias, tipoalteracaoesocial, acaoimportacaozen, evespecificoesocial1299, utilcalcautomatizado, impesocial, arrendcenthora, senhafap, considerareducao13media, datacompensacaocruzada, utilizaguiarescisoriaauto, tipoenvioedoc, formageracaofgts, dataopcaoutilguiarescauto, competopcaocalcpatronal) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datainicial, OLD.processocontrisocialresc, OLD.folhahoradia, OLD.horasnot5230, OLD.valorarred, OLD.prazopgtomensal, OLD.vacinfreq, OLD.pgtofolhamensaladto, OLD.pgtoadmmens, OLD.formacalctrocaescalames, OLD.eventoiniesocial, OLD.pgtodemmens, OLD.sepdsrhrmensfer, OLD.sepdsrmens, OLD.pagasalfamintermitente, OLD.calculofaltas, OLD.perdedsrfaltas, OLD.utilestrutsal, OLD.codigoestrutsal, OLD.utilbeneficio, OLD.pagaferiado, OLD.utilvaletransp, OLD.utilrefeicao, OLD.utilsinchist, OLD.organograma, OLD.horacent, OLD.utilrateio, OLD.codigogrupotabelacontabil, OLD.contabiliza, OLD.codigoempctb, OLD.rateiogerencial, OLD.insssepar, OLD.escalamensalhor, OLD.codigoassiduidade, OLD.registroinformat, OLD.percpis, OLD.salfamadmdem, OLD.escalamensalprof, OLD.utilcalcprof, OLD.codigopercalculo, OLD.utilppp, OLD.gerarais, OLD.numeroconvenio, OLD.gpscompensarprim, OLD.horanormalcritrat, OLD.depend13dirfinforme, OLD.datacompensacaoterceiros, OLD.compensacaogps, OLD.competperagrupador, OLD.formageracaodarf, OLD.datainicialcalcmovusu, OLD.datafinalcalcmovusu, OLD.datainicialprovusu, OLD.datafinalprovusu, OLD.datainicialcalcvtrusu, OLD.utilobratomadortabferiado, OLD.sistemaanuidade, OLD.datafinalcalcvtrusu, OLD.codigoanuidade, OLD.separarhorasapt, OLD.separarferiasind, OLD.diversasativcnae, OLD.pagafastmensalista, OLD.prorrogalicmat, OLD.codigousuariocalculando, OLD.gerardebitofolhactr, OLD.utilfuncao, OLD.codigolayoutcontabilizacao, OLD.anuidadetemposervico, OLD.pontotoleran, OLD.pontotolerandia, OLD.pontocontrole, OLD.utilfaixaremun, OLD.utillimiteminferias, OLD.tipoalteracaoesocial, OLD.acaoimportacaozen, OLD.evespecificoesocial1299, OLD.utilcalcautomatizado, OLD.impesocial, OLD.arrendcenthora, OLD.senhafap, OLD.considerareducao13media, OLD.datacompensacaocruzada, OLD.utilizaguiarescisoriaauto, OLD.tipoenvioedoc, OLD.formageracaofgts, OLD.dataopcaoutilguiarescauto, OLD.competopcaocalcpatronal); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgestabfpaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgestabfpaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CFGESTABFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, codigotabferescala, centralfgts, codigoestcentrfgts, categfgts, codigobancofgts, numeroagenciafgts, contafgts, digitocontafgts, empresafgts, codigoimposto, variacaoimposto, codigotabgps, fichareg, primeiradeclcaged, nomepreposto, codigoestabsind, codigoativsind, codigoestabctb, codigotabgpsoutemp, centralrecolhsind, sindicalizada, particpat, patservproprio, patadmcozinha, patrefeicaoconv, patrefeicaotransp, percadiantamento, patcestaalimento, tipocontroleponto, patalimconvenio, indpcd, codigoprocessojudadmmenapr, menoraprendizentid, codigoprocessojudadmpcd, indmenaprendiz, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.datainicial, NEW.codigotabferescala, NEW.centralfgts, NEW.codigoestcentrfgts, NEW.categfgts, NEW.codigobancofgts, NEW.numeroagenciafgts, NEW.contafgts, NEW.digitocontafgts, NEW.empresafgts, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigotabgps, NEW.fichareg, NEW.primeiradeclcaged, NEW.nomepreposto, NEW.codigoestabsind, NEW.codigoativsind, NEW.codigoestabctb, NEW.codigotabgpsoutemp, NEW.centralrecolhsind, NEW.sindicalizada, NEW.particpat, NEW.patservproprio, NEW.patadmcozinha, NEW.patrefeicaoconv, NEW.patrefeicaotransp, NEW.percadiantamento, NEW.patcestaalimento, NEW.tipocontroleponto, NEW.patalimconvenio, NEW.indpcd, NEW.codigoprocessojudadmmenapr, NEW.menoraprendizentid, NEW.codigoprocessojudadmpcd, NEW.indmenaprendiz, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgestabfpaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgestabfpaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CFGESTABFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, codigotabferescala, centralfgts, codigoestcentrfgts, categfgts, codigobancofgts, numeroagenciafgts, contafgts, digitocontafgts, empresafgts, codigoimposto, variacaoimposto, codigotabgps, fichareg, primeiradeclcaged, nomepreposto, codigoestabsind, codigoativsind, codigoestabctb, codigotabgpsoutemp, centralrecolhsind, sindicalizada, particpat, patservproprio, patadmcozinha, patrefeicaoconv, patrefeicaotransp, percadiantamento, patcestaalimento, tipocontroleponto, patalimconvenio, indpcd, codigoprocessojudadmmenapr, menoraprendizentid, codigoprocessojudadmpcd, indmenaprendiz, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.datainicial, OLD.codigotabferescala, OLD.centralfgts, OLD.codigoestcentrfgts, OLD.categfgts, OLD.codigobancofgts, OLD.numeroagenciafgts, OLD.contafgts, OLD.digitocontafgts, OLD.empresafgts, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigotabgps, OLD.fichareg, OLD.primeiradeclcaged, OLD.nomepreposto, OLD.codigoestabsind, OLD.codigoativsind, OLD.codigoestabctb, OLD.codigotabgpsoutemp, OLD.centralrecolhsind, OLD.sindicalizada, OLD.particpat, OLD.patservproprio, OLD.patadmcozinha, OLD.patrefeicaoconv, OLD.patrefeicaotransp, OLD.percadiantamento, OLD.patcestaalimento, OLD.tipocontroleponto, OLD.patalimconvenio, OLD.indpcd, OLD.codigoprocessojudadmmenapr, OLD.menoraprendizentid, OLD.codigoprocessojudadmpcd, OLD.indmenaprendiz, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CFGESTABFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, codigotabferescala, centralfgts, codigoestcentrfgts, categfgts, codigobancofgts, numeroagenciafgts, contafgts, digitocontafgts, empresafgts, codigoimposto, variacaoimposto, codigotabgps, fichareg, primeiradeclcaged, nomepreposto, codigoestabsind, codigoativsind, codigoestabctb, codigotabgpsoutemp, centralrecolhsind, sindicalizada, particpat, patservproprio, patadmcozinha, patrefeicaoconv, patrefeicaotransp, percadiantamento, patcestaalimento, tipocontroleponto, patalimconvenio, indpcd, codigoprocessojudadmmenapr, menoraprendizentid, codigoprocessojudadmpcd, indmenaprendiz, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.datainicial, NEW.codigotabferescala, NEW.centralfgts, NEW.codigoestcentrfgts, NEW.categfgts, NEW.codigobancofgts, NEW.numeroagenciafgts, NEW.contafgts, NEW.digitocontafgts, NEW.empresafgts, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigotabgps, NEW.fichareg, NEW.primeiradeclcaged, NEW.nomepreposto, NEW.codigoestabsind, NEW.codigoativsind, NEW.codigoestabctb, NEW.codigotabgpsoutemp, NEW.centralrecolhsind, NEW.sindicalizada, NEW.particpat, NEW.patservproprio, NEW.patadmcozinha, NEW.patrefeicaoconv, NEW.patrefeicaotransp, NEW.percadiantamento, NEW.patcestaalimento, NEW.tipocontroleponto, NEW.patalimconvenio, NEW.indpcd, NEW.codigoprocessojudadmmenapr, NEW.menoraprendizentid, NEW.codigoprocessojudadmpcd, NEW.indmenaprendiz, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgestabfpabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgestabfpabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CFGESTABFPAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, codigotabferescala, centralfgts, codigoestcentrfgts, categfgts, codigobancofgts, numeroagenciafgts, contafgts, digitocontafgts, empresafgts, codigoimposto, variacaoimposto, codigotabgps, fichareg, primeiradeclcaged, nomepreposto, codigoestabsind, codigoativsind, codigoestabctb, codigotabgpsoutemp, centralrecolhsind, sindicalizada, particpat, patservproprio, patadmcozinha, patrefeicaoconv, patrefeicaotransp, percadiantamento, patcestaalimento, tipocontroleponto, patalimconvenio, indpcd, codigoprocessojudadmmenapr, menoraprendizentid, codigoprocessojudadmpcd, indmenaprendiz, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.datainicial, OLD.codigotabferescala, OLD.centralfgts, OLD.codigoestcentrfgts, OLD.categfgts, OLD.codigobancofgts, OLD.numeroagenciafgts, OLD.contafgts, OLD.digitocontafgts, OLD.empresafgts, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigotabgps, OLD.fichareg, OLD.primeiradeclcaged, OLD.nomepreposto, OLD.codigoestabsind, OLD.codigoativsind, OLD.codigoestabctb, OLD.codigotabgpsoutemp, OLD.centralrecolhsind, OLD.sindicalizada, OLD.particpat, OLD.patservproprio, OLD.patadmcozinha, OLD.patrefeicaoconv, OLD.patrefeicaotransp, OLD.percadiantamento, OLD.patcestaalimento, OLD.tipocontroleponto, OLD.patalimconvenio, OLD.indpcd, OLD.codigoprocessojudadmmenapr, OLD.menoraprendizentid, OLD.codigoprocessojudadmpcd, OLD.indmenaprendiz, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgestabfpalotacaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgestabfpalotacaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CFGESTABFPALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.competfinal); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgestabfpalotacaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgestabfpalotacaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CFGESTABFPALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.competfinal); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CFGESTABFPALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.competfinal); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cfgestabfpalotacaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cfgestabfpalotacaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CFGESTABFPALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CFGESTABFPALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.competfinal); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="chequedetalheadf" procedure_source="CREATE OR REPLACE FUNCTION public.chequedetalheadf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE &#010;AStatusAtual smallint;&#010;BEGIN&#010;  SELECT CHD.STATUSCHEQUE &#010;  INTO AStatusAtual&#010;  FROM CHEQUEDETALHE CHD&#010;  WHERE CHD.CODIGOESCRIT = OLD.CODIGOESCRIT&#010;    AND CHD.CODIGOCHEQUE = OLD.CODIGOCHEQUE&#010;  ORDER BY CHD.SEQCHEQUEDET DESC LIMIT 1;&#010;  IF (AStatusAtual &gt; 0) THEN&#010;BEGIN&#010;UPDATE FPRCHEQUE SET&#010;STATUSCHEQUE = AStatusAtual&#010;WHERE FPRCHEQUE.CODIGOESCRIT = OLD.CODIGOESCRIT&#010;AND FPRCHEQUE.CODIGOCHEQUE = OLD.CODIGOCHEQUE;&#010;END;&#010;  END IF;&#010;  RETURN OLD;&#010;END;&#010;$function$&#010;"/>
<ROW pro_key="chequedetalheaif" procedure_source="CREATE OR REPLACE FUNCTION public.chequedetalheaif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  UPDATE FPRCHEQUE SET&#010;  STATUSCHEQUE = NEW.STATUSCHEQUE&#010;  WHERE FPRCHEQUE.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;    AND FPRCHEQUE.CODIGOCHEQUE = NEW.CODIGOCHEQUE;&#010;  RETURN new;&#010;END;&#010; $function$&#010;"/>
<ROW pro_key="clcrequestbif" procedure_source="CREATE OR REPLACE FUNCTION public.clcrequestbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.ID IS NULL) THEN&#013;&#010;    NEW.ID = NEXTVAL(&apos;genclcrequest&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;genclcrequest&apos;) INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO tmp FROM genclcrequest;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; tmp) LOOP &#013;&#010;SELECT nextval(&apos;genclcrequest&apos;) INTO tmp;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="cnaeestabaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.cnaeestabaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CNAEESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CNAEESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoativfederal, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.codigoativfederal, NEW.datainicial, NEW.datafinal); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cnaeestabauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cnaeestabauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CNAEESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CNAEESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoativfederal, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.codigoativfederal, OLD.datainicial, OLD.datafinal); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CNAEESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CNAEESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoativfederal, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.codigoativfederal, NEW.datainicial, NEW.datafinal); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="cnaeestabbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.cnaeestabbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CNAEESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CNAEESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoativfederal, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.codigoativfederal, OLD.datainicial, OLD.datafinal); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="conselhoprofisaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.conselhoprofisaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONSELHOPROFISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONSELHOPROFISHS(SEQHISTORICO, OPERACAO, codigoconselho, nomeconselho, siglaconselho, enderconselho, numeroender, complender, bairroconselho, siglaestado, codigomunic, cepconselho, dddfone, numerofone, endereletr, paginainter, codigotipolograd, tipoconselhoprofis) &#013;&#010;  VALUES (GEN, 1, NEW.codigoconselho, NEW.nomeconselho, NEW.siglaconselho, NEW.enderconselho, NEW.numeroender, NEW.complender, NEW.bairroconselho, NEW.siglaestado, NEW.codigomunic, NEW.cepconselho, NEW.dddfone, NEW.numerofone, NEW.endereletr, NEW.paginainter, NEW.codigotipolograd, NEW.tipoconselhoprofis); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="conselhoprofisauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.conselhoprofisauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONSELHOPROFISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONSELHOPROFISHS(SEQHISTORICO, OPERACAO, codigoconselho, nomeconselho, siglaconselho, enderconselho, numeroender, complender, bairroconselho, siglaestado, codigomunic, cepconselho, dddfone, numerofone, endereletr, paginainter, codigotipolograd, tipoconselhoprofis) &#013;&#010;  VALUES (GEN, 2, OLD.codigoconselho, OLD.nomeconselho, OLD.siglaconselho, OLD.enderconselho, OLD.numeroender, OLD.complender, OLD.bairroconselho, OLD.siglaestado, OLD.codigomunic, OLD.cepconselho, OLD.dddfone, OLD.numerofone, OLD.endereletr, OLD.paginainter, OLD.codigotipolograd, OLD.tipoconselhoprofis); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONSELHOPROFISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONSELHOPROFISHS(SEQHISTORICO, OPERACAO, codigoconselho, nomeconselho, siglaconselho, enderconselho, numeroender, complender, bairroconselho, siglaestado, codigomunic, cepconselho, dddfone, numerofone, endereletr, paginainter, codigotipolograd, tipoconselhoprofis) &#013;&#010;  VALUES (GEN, 3, NEW.codigoconselho, NEW.nomeconselho, NEW.siglaconselho, NEW.enderconselho, NEW.numeroender, NEW.complender, NEW.bairroconselho, NEW.siglaestado, NEW.codigomunic, NEW.cepconselho, NEW.dddfone, NEW.numerofone, NEW.endereletr, NEW.paginainter, NEW.codigotipolograd, NEW.tipoconselhoprofis); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="conselhoprofisbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.conselhoprofisbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONSELHOPROFISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONSELHOPROFISHS(SEQHISTORICO, OPERACAO, codigoconselho, nomeconselho, siglaconselho, enderconselho, numeroender, complender, bairroconselho, siglaestado, codigomunic, cepconselho, dddfone, numerofone, endereletr, paginainter, codigotipolograd, tipoconselhoprofis) &#013;&#010;  VALUES (GEN, 4, OLD.codigoconselho, OLD.nomeconselho, OLD.siglaconselho, OLD.enderconselho, OLD.numeroender, OLD.complender, OLD.bairroconselho, OLD.siglaestado, OLD.codigomunic, OLD.cepconselho, OLD.dddfone, OLD.numerofone, OLD.endereletr, OLD.paginainter, OLD.codigotipolograd, OLD.tipoconselhoprofis); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="contadoraihsf" procedure_source="CREATE OR REPLACE FUNCTION public.contadoraihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONTADORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONTADORHS(SEQHISTORICO, OPERACAO, codigocont, datainicial, nomecont, cependercont, enderecocont, numendercont, complendercont, bairroendercont, siglaestado, codigomunic, dataalterender, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, tipoinscr, inscrfederal, numerorg, orgaoemissorrg, siglaestadorg, datarg, numeroreg, tituloprofis, qualificacao, ufcrc, numseqcrc, dtcrc, usuariosat, senhasat, inscrmunic, email, datanasc, paginainternet, codigotipolograd, cpfrespcaepfcont, insccaepfcont, tipocaepfcont, tipoalteracaoesocial, transferidoousecundario) &#013;&#010;  VALUES (GEN, 1, NEW.codigocont, NEW.datainicial, NEW.nomecont, NEW.cependercont, NEW.enderecocont, NEW.numendercont, NEW.complendercont, NEW.bairroendercont, NEW.siglaestado, NEW.codigomunic, NEW.dataalterender, NEW.dddfone, NEW.numerofone, NEW.ramal, NEW.dddfax, NEW.dddcelular, NEW.numerocelular, NEW.numerofax, NEW.tipoinscr, NEW.inscrfederal, NEW.numerorg, NEW.orgaoemissorrg, NEW.siglaestadorg, NEW.datarg, NEW.numeroreg, NEW.tituloprofis, NEW.qualificacao, NEW.ufcrc, NEW.numseqcrc, NEW.dtcrc, NEW.usuariosat, NEW.senhasat, NEW.inscrmunic, NEW.email, NEW.datanasc, NEW.paginainternet, NEW.codigotipolograd, NEW.cpfrespcaepfcont, NEW.insccaepfcont, NEW.tipocaepfcont, NEW.tipoalteracaoesocial, NEW.transferidoousecundario); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="contadorauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.contadorauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONTADORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONTADORHS(SEQHISTORICO, OPERACAO, codigocont, datainicial, nomecont, cependercont, enderecocont, numendercont, complendercont, bairroendercont, siglaestado, codigomunic, dataalterender, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, tipoinscr, inscrfederal, numerorg, orgaoemissorrg, siglaestadorg, datarg, numeroreg, tituloprofis, qualificacao, ufcrc, numseqcrc, dtcrc, usuariosat, senhasat, inscrmunic, email, datanasc, paginainternet, codigotipolograd, cpfrespcaepfcont, insccaepfcont, tipocaepfcont, tipoalteracaoesocial, transferidoousecundario) &#013;&#010;  VALUES (GEN, 2, OLD.codigocont, OLD.datainicial, OLD.nomecont, OLD.cependercont, OLD.enderecocont, OLD.numendercont, OLD.complendercont, OLD.bairroendercont, OLD.siglaestado, OLD.codigomunic, OLD.dataalterender, OLD.dddfone, OLD.numerofone, OLD.ramal, OLD.dddfax, OLD.dddcelular, OLD.numerocelular, OLD.numerofax, OLD.tipoinscr, OLD.inscrfederal, OLD.numerorg, OLD.orgaoemissorrg, OLD.siglaestadorg, OLD.datarg, OLD.numeroreg, OLD.tituloprofis, OLD.qualificacao, OLD.ufcrc, OLD.numseqcrc, OLD.dtcrc, OLD.usuariosat, OLD.senhasat, OLD.inscrmunic, OLD.email, OLD.datanasc, OLD.paginainternet, OLD.codigotipolograd, OLD.cpfrespcaepfcont, OLD.insccaepfcont, OLD.tipocaepfcont, OLD.tipoalteracaoesocial, OLD.transferidoousecundario); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONTADORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONTADORHS(SEQHISTORICO, OPERACAO, codigocont, datainicial, nomecont, cependercont, enderecocont, numendercont, complendercont, bairroendercont, siglaestado, codigomunic, dataalterender, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, tipoinscr, inscrfederal, numerorg, orgaoemissorrg, siglaestadorg, datarg, numeroreg, tituloprofis, qualificacao, ufcrc, numseqcrc, dtcrc, usuariosat, senhasat, inscrmunic, email, datanasc, paginainternet, codigotipolograd, cpfrespcaepfcont, insccaepfcont, tipocaepfcont, tipoalteracaoesocial, transferidoousecundario) &#013;&#010;  VALUES (GEN, 3, NEW.codigocont, NEW.datainicial, NEW.nomecont, NEW.cependercont, NEW.enderecocont, NEW.numendercont, NEW.complendercont, NEW.bairroendercont, NEW.siglaestado, NEW.codigomunic, NEW.dataalterender, NEW.dddfone, NEW.numerofone, NEW.ramal, NEW.dddfax, NEW.dddcelular, NEW.numerocelular, NEW.numerofax, NEW.tipoinscr, NEW.inscrfederal, NEW.numerorg, NEW.orgaoemissorrg, NEW.siglaestadorg, NEW.datarg, NEW.numeroreg, NEW.tituloprofis, NEW.qualificacao, NEW.ufcrc, NEW.numseqcrc, NEW.dtcrc, NEW.usuariosat, NEW.senhasat, NEW.inscrmunic, NEW.email, NEW.datanasc, NEW.paginainternet, NEW.codigotipolograd, NEW.cpfrespcaepfcont, NEW.insccaepfcont, NEW.tipocaepfcont, NEW.tipoalteracaoesocial, NEW.transferidoousecundario); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="contadorbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.contadorbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;CONTADORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONTADORHS(SEQHISTORICO, OPERACAO, codigocont, datainicial, nomecont, cependercont, enderecocont, numendercont, complendercont, bairroendercont, siglaestado, codigomunic, dataalterender, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, tipoinscr, inscrfederal, numerorg, orgaoemissorrg, siglaestadorg, datarg, numeroreg, tituloprofis, qualificacao, ufcrc, numseqcrc, dtcrc, usuariosat, senhasat, inscrmunic, email, datanasc, paginainternet, codigotipolograd, cpfrespcaepfcont, insccaepfcont, tipocaepfcont, tipoalteracaoesocial, transferidoousecundario) &#013;&#010;  VALUES (GEN, 4, OLD.codigocont, OLD.datainicial, OLD.nomecont, OLD.cependercont, OLD.enderecocont, OLD.numendercont, OLD.complendercont, OLD.bairroendercont, OLD.siglaestado, OLD.codigomunic, OLD.dataalterender, OLD.dddfone, OLD.numerofone, OLD.ramal, OLD.dddfax, OLD.dddcelular, OLD.numerocelular, OLD.numerofax, OLD.tipoinscr, OLD.inscrfederal, OLD.numerorg, OLD.orgaoemissorrg, OLD.siglaestadorg, OLD.datarg, OLD.numeroreg, OLD.tituloprofis, OLD.qualificacao, OLD.ufcrc, OLD.numseqcrc, OLD.dtcrc, OLD.usuariosat, OLD.senhasat, OLD.inscrmunic, OLD.email, OLD.datanasc, OLD.paginainternet, OLD.codigotipolograd, OLD.cpfrespcaepfcont, OLD.insccaepfcont, OLD.tipocaepfcont, OLD.tipoalteracaoesocial, OLD.transferidoousecundario); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="convocacaointermitenteaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.convocacaointermitenteaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CONVOCACAOINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONVOCACAOINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoconvocacao, descricao, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoconvocacao, NEW.descricao, NEW.datainicial, NEW.datafinal); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="convocacaointermitenteauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.convocacaointermitenteauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CONVOCACAOINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONVOCACAOINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoconvocacao, descricao, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoconvocacao, OLD.descricao, OLD.datainicial, OLD.datafinal); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;CONVOCACAOINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONVOCACAOINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoconvocacao, descricao, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoconvocacao, NEW.descricao, NEW.datainicial, NEW.datafinal); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="convocacaointermitentebdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.convocacaointermitentebdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;CONVOCACAOINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO CONVOCACAOINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoconvocacao, descricao, datainicial, datafinal) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoconvocacao, OLD.descricao, OLD.datainicial, OLD.datafinal); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="debitofolhabif" procedure_source="CREATE OR REPLACE FUNCTION public.debitofolhabif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.CHAVEDEBITOFOLHA is null) THEN&#013;&#010;    new.CHAVEDEBITOFOLHA = NEXTVAL(&apos;gen_chavedebitofolha&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_chavedebitofolha&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_chavedebitofolha;&#013;&#010;END;&#013;&#010;WHILE (NEW.CHAVEDEBITOFOLHA &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_chavedebitofolha&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="dependenteaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.dependenteaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;DEPENDENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO DEPENDENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigodepend, cpfdepend, nomedepend, datanasc, parentesco, sexo, grauinstr, estadocivil, idadelimsalfam, formacontroleir, incapaztrabalhar, idadelimir, datavacin, siglaestado, nacionalidade, codigomunic, cartorio, livroreg, folhalivroreg, numeroreg, entregacert, controlevacin, numeroconvenio, fumante, consomealcool, idademincreche, matricula, numdeclarnascvivo, databaixa, idadelimcreche, tipoalteracaoesocial, ehdependenteir, descrdep, datafimir) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigodepend, NEW.cpfdepend, NEW.nomedepend, NEW.datanasc, NEW.parentesco, NEW.sexo, NEW.grauinstr, NEW.estadocivil, NEW.idadelimsalfam, NEW.formacontroleir, NEW.incapaztrabalhar, NEW.idadelimir, NEW.datavacin, NEW.siglaestado, NEW.nacionalidade, NEW.codigomunic, NEW.cartorio, NEW.livroreg, NEW.folhalivroreg, NEW.numeroreg, NEW.entregacert, NEW.controlevacin, NEW.numeroconvenio, NEW.fumante, NEW.consomealcool, NEW.idademincreche, NEW.matricula, NEW.numdeclarnascvivo, NEW.databaixa, NEW.idadelimcreche, NEW.tipoalteracaoesocial, NEW.ehdependenteir, NEW.descrdep, NEW.datafimir); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="dependenteauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.dependenteauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;DEPENDENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO DEPENDENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigodepend, cpfdepend, nomedepend, datanasc, parentesco, sexo, grauinstr, estadocivil, idadelimsalfam, formacontroleir, incapaztrabalhar, idadelimir, datavacin, siglaestado, nacionalidade, codigomunic, cartorio, livroreg, folhalivroreg, numeroreg, entregacert, controlevacin, numeroconvenio, fumante, consomealcool, idademincreche, matricula, numdeclarnascvivo, databaixa, idadelimcreche, tipoalteracaoesocial, ehdependenteir, descrdep, datafimir) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigodepend, OLD.cpfdepend, OLD.nomedepend, OLD.datanasc, OLD.parentesco, OLD.sexo, OLD.grauinstr, OLD.estadocivil, OLD.idadelimsalfam, OLD.formacontroleir, OLD.incapaztrabalhar, OLD.idadelimir, OLD.datavacin, OLD.siglaestado, OLD.nacionalidade, OLD.codigomunic, OLD.cartorio, OLD.livroreg, OLD.folhalivroreg, OLD.numeroreg, OLD.entregacert, OLD.controlevacin, OLD.numeroconvenio, OLD.fumante, OLD.consomealcool, OLD.idademincreche, OLD.matricula, OLD.numdeclarnascvivo, OLD.databaixa, OLD.idadelimcreche, OLD.tipoalteracaoesocial, OLD.ehdependenteir, OLD.descrdep, OLD.datafimir); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;DEPENDENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO DEPENDENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigodepend, cpfdepend, nomedepend, datanasc, parentesco, sexo, grauinstr, estadocivil, idadelimsalfam, formacontroleir, incapaztrabalhar, idadelimir, datavacin, siglaestado, nacionalidade, codigomunic, cartorio, livroreg, folhalivroreg, numeroreg, entregacert, controlevacin, numeroconvenio, fumante, consomealcool, idademincreche, matricula, numdeclarnascvivo, databaixa, idadelimcreche, tipoalteracaoesocial, ehdependenteir, descrdep, datafimir) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigodepend, NEW.cpfdepend, NEW.nomedepend, NEW.datanasc, NEW.parentesco, NEW.sexo, NEW.grauinstr, NEW.estadocivil, NEW.idadelimsalfam, NEW.formacontroleir, NEW.incapaztrabalhar, NEW.idadelimir, NEW.datavacin, NEW.siglaestado, NEW.nacionalidade, NEW.codigomunic, NEW.cartorio, NEW.livroreg, NEW.folhalivroreg, NEW.numeroreg, NEW.entregacert, NEW.controlevacin, NEW.numeroconvenio, NEW.fumante, NEW.consomealcool, NEW.idademincreche, NEW.matricula, NEW.numdeclarnascvivo, NEW.databaixa, NEW.idadelimcreche, NEW.tipoalteracaoesocial, NEW.ehdependenteir, NEW.descrdep, NEW.datafimir); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="dependentebdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.dependentebdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;DEPENDENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO DEPENDENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigodepend, cpfdepend, nomedepend, datanasc, parentesco, sexo, grauinstr, estadocivil, idadelimsalfam, formacontroleir, incapaztrabalhar, idadelimir, datavacin, siglaestado, nacionalidade, codigomunic, cartorio, livroreg, folhalivroreg, numeroreg, entregacert, controlevacin, numeroconvenio, fumante, consomealcool, idademincreche, matricula, numdeclarnascvivo, databaixa, idadelimcreche, tipoalteracaoesocial, ehdependenteir, descrdep, datafimir) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigodepend, OLD.cpfdepend, OLD.nomedepend, OLD.datanasc, OLD.parentesco, OLD.sexo, OLD.grauinstr, OLD.estadocivil, OLD.idadelimsalfam, OLD.formacontroleir, OLD.incapaztrabalhar, OLD.idadelimir, OLD.datavacin, OLD.siglaestado, OLD.nacionalidade, OLD.codigomunic, OLD.cartorio, OLD.livroreg, OLD.folhalivroreg, OLD.numeroreg, OLD.entregacert, OLD.controlevacin, OLD.numeroconvenio, OLD.fumante, OLD.consomealcool, OLD.idademincreche, OLD.matricula, OLD.numdeclarnascvivo, OLD.databaixa, OLD.idadelimcreche, OLD.tipoalteracaoesocial, OLD.ehdependenteir, OLD.descrdep, OLD.datafimir); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="documentoacerto" procedure_source="CREATE OR REPLACE FUNCTION public.documentoacerto(pcodigoescrit integer, pcodigoacerto integer, OUT documentos character varying)&#010; RETURNS character varying&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;documento varchar(10);&#013;&#010;curDados cursor for(SELECT DISTINCT &#013;&#010;    CASE&#013;&#010;      WHEN FCP.CodigoPagarCab &gt; 0 THEN CAST(FCP.CodigoPagarCab AS varchar(10))&#013;&#010;      WHEN FCR.NUMERODCTOCR &lt;&gt; &apos;&apos; THEN FCR.NUMERODCTOCR&#013;&#010;      WHEN FSN.SERIENS || FSN.NUMERONS &lt;&gt; &apos;&apos; THEN FSN.SERIENS || FSN.NUMERONS  &#013;&#010;      ELSE &apos;&apos; &#013;&#010;    END Doc&#013;&#010;  FROM FPRACERTO AC&#013;&#010;  LEFT JOIN FPRACERTOCP FCP ON FCP.CodigoEscrit = AC.CodigoEscrit AND FCP.CodigoAcerto = AC.CodigoAcerto&#013;&#010;  LEFT JOIN FPRACERTOCXFINCR FCR ON FCR.CodigoEscrit = AC.CodigoEscrit AND FCR.CodigoAcerto = AC.CodigoAcerto&#013;&#010;  LEFT JOIN FPRACERTOCXFINSERVICONOTA FSN ON FSN.CodigoEscrit = AC.CodigoEscrit AND FSN.CodigoAcerto = AC.CodigoAcerto&#013;&#010;  WHERE AC.CodigoEscrit = PCODIGOESCRIT&#013;&#010;    AND AC.CodigoAcerto = PCODIGOACERTO&#013;&#010;  ORDER BY Doc);&#013;&#010;BEGIN&#013;&#010;  DOCUMENTOS = &apos;&apos;;&#013;&#010;  OPEN curDados;&#013;&#010;  &#013;&#010;  WHILE (1=1) LOOP&#013;&#010;BEGIN&#013;&#010;FETCH curDados INTO documento;&#013;&#010;IF NOT FOUND /*(row_count = 0)*/ THEN&#013;&#010;EXIT;&#013;&#010;END IF;&#013;&#010;IF (DOCUMENTOS &lt;&gt; &apos;&apos;) THEN&#013;&#010;DOCUMENTOS = DOCUMENTOS || &apos;;&apos;;&#013;&#010;DOCUMENTOS = DOCUMENTOS || documento;&#013;&#010;END IF;&#013;&#010;END;&#013;&#010;  END LOOP;&#013;&#010;  CLOSE curDados;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="duplicatasaipgtobdf" procedure_source="CREATE OR REPLACE FUNCTION public.duplicatasaipgtobdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;DELETE FROM LCTOFISSAIRETIDOPAGAMENTO&#010;WHERE CODIGOEMPRESA = old.CODIGOEMPRESA&#010;AND CODIGOESTAB = old.CODIGOESTAB&#010;AND CHAVEDUPLICATASAI = old.CHAVEDUPLICATASAI&#010;AND NUMEROPARCELA = old.NUMEROPARCELA&#010;AND SEQDUPLICATA = old.SEQ;&#010;RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="ecfcontapartebaif" procedure_source="CREATE OR REPLACE FUNCTION public.ecfcontapartebaif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;declare &#010;varValorDeb Numeric(14,2);&#010;varValorCred Numeric(14,2);&#010;BEGIN&#010;  IF (new.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) THEN&#010;varValorCred = new.VALORCONTA;&#010;varValorDeb  = 0;&#010;  ELSE&#010;varValorCred = 0;&#010;varValorDeb  = new.VALORCONTA;&#010;  END IF;&#010;  UPDATE ECFMOVCONTAPARTEB&#010;     SET VLRCREDPARTEA = VLRCREDPARTEA + varValorCred,&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  + varValorDeb&#010;   WHERE CODIGOEMPRESA = new.CODIGOEMPRESA&#010;     AND TIPOIMPOSTO   = new.TIPOIMPOSTO&#010;     AND CODIGOCONTAB  = new.CODIGOCONTAB&#010;     AND DATASALDO     = new.DATALCTOFIS;&#010;  IF /*(row_count = 0)*/NOT FOUND THEN&#010;BEGIN&#010;INSERT INTO ECFMOVCONTAPARTEB (CODIGOEMPRESA, TIPOIMPOSTO, CODIGOCONTAB,&#010;DATASALDO, VLRCREDPARTEA, VLRDEBPARTEA, VLRCREDPARTEB, VLRDEBPARTEB)&#010;VALUES (new.CODIGOEMPRESA, new.TIPOIMPOSTO, new.CODIGOCONTAB,&#010;new.DATALCTOFIS, varValorCred, varValorDeb, 0, 0);&#010;END;&#010;  END IF;&#010;  RETURN new;&#010;END;&#010;$function$&#010;"/>
<ROW pro_key="ecfcontapartebauf" procedure_source="CREATE OR REPLACE FUNCTION public.ecfcontapartebauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;declare &#010;varValorDeb Numeric(14,2);&#010;varValorCred Numeric(14,2);&#010;BEGIN&#010;  IF (new.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) THEN&#010;    varValorCred = new.VALORCONTA;&#010;    varValorDeb  = 0;&#010;  ELSE&#010;    varValorCred = 0;&#010;    varValorDeb  = new.VALORCONTA;&#010;  END IF;&#010;  UPDATE ECFMOVCONTAPARTEB&#010;     SET VLRCREDPARTEA = VLRCREDPARTEA + varValorCred,&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  + varValorDeb&#010;   WHERE CODIGOEMPRESA = new.CODIGOEMPRESA&#010;     AND TIPOIMPOSTO   = new.TIPOIMPOSTO&#010;     AND CODIGOCONTAB  = new.CODIGOCONTAB&#010;     AND DATASALDO     = new.DATALCTOFIS;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="ecfcontapartebbd" procedure_source="CREATE OR REPLACE FUNCTION public.ecfcontapartebbd()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;&#010;DECLARE &#010;varValorDeb Numeric(14,2);&#010;varValorCred Numeric(14,2);&#010;varValorMovimento Numeric(14,2);&#010;BEGIN&#010;  IF (old.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) THEN&#010;    varValorCred = old.VALORCONTA;&#010;    varValorDeb  = 0;&#010;  ELSE&#010;    varValorCred = 0;&#010;    varValorDeb  = old.VALORCONTA;&#010;  END IF;&#010;  UPDATE ECFMOVCONTAPARTEB&#010;     SET VLRCREDPARTEA = VLRCREDPARTEA - varValorCred,&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  - varValorDeb&#010;   WHERE CODIGOEMPRESA = old.CODIGOEMPRESA&#010;     AND TIPOIMPOSTO   = old.TIPOIMPOSTO&#010;     AND CODIGOCONTAB  = old.CODIGOCONTAB&#010;     AND DATASALDO     = old.DATALCTOFIS;&#010;  SELECT M.VLRCREDPARTEA +&#010;         M.VLRDEBPARTEA  +&#010;         M.VLRCREDPARTEB +&#010;         M.VLRDEBPARTEB&#010;INTO varValorMovimento&#010;    FROM ECFMOVCONTAPARTEB M&#010;   WHERE M.CODIGOEMPRESA = old.CODIGOEMPRESA&#010;     AND M.TIPOIMPOSTO   = old.TIPOIMPOSTO&#010;     AND M.CODIGOCONTAB  = old.CODIGOCONTAB&#010;     AND M.DATASALDO     = old.DATALCTOFIS;&#010;  IF (varValorMovimento = 0) THEN&#010;DELETE FROM ECFMOVCONTAPARTEB D&#010;WHERE D.CODIGOEMPRESA = old.CODIGOEMPRESA&#010;AND D.TIPOIMPOSTO   = old.TIPOIMPOSTO&#010;AND D.CODIGOCONTAB  = old.CODIGOCONTAB&#010;AND D.DATASALDO     = old.DATALCTOFIS;&#010;  END IF;&#010;  RETURN old;&#010;END;&#010;$function$&#010;"/>
<ROW pro_key="ecfcontapartebbuf" procedure_source="CREATE OR REPLACE FUNCTION public.ecfcontapartebbuf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE &#010;varValorDeb Numeric(14,2);&#010;varValorCred Numeric(14,2);&#010;BEGIN&#010;  IF (old.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) THEN&#010;    varValorCred = old.VALORCONTA;&#010;    varValorDeb  = 0;&#010;  ELSE&#010;    varValorCred = 0;&#010;    varValorDeb  = old.VALORCONTA;&#010;  END IF;&#010;  UPDATE ECFMOVCONTAPARTEB&#010;     SET VLRCREDPARTEA = VLRCREDPARTEA - varValorCred,&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  - varValorDeb&#010;   WHERE CODIGOEMPRESA = new.CODIGOEMPRESA&#010;     AND TIPOIMPOSTO   = new.TIPOIMPOSTO&#010;     AND CODIGOCONTAB  = new.CODIGOCONTAB&#010;     AND DATASALDO     = new.DATALCTOFIS;&#010;  RETURN NEW;&#010;END;&#010;$function$&#010;"/>
<ROW pro_key="ecflctopartebsemreflexoaif" procedure_source="CREATE OR REPLACE FUNCTION public.ecflctopartebsemreflexoaif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;VARVALORDEB NUMERIC(14,2);&#013;&#010;VARVALORCRED NUMERIC(14,2);&#013;&#010;BEGIN&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  IF (NEW.INDVALORLCTO = &apos;CR&apos;/*Credito*/) THEN&#013;&#010;    VARVALORCRED = NEW.VALORLCTO;&#013;&#010;    VARVALORDEB  = 0;&#013;&#010;  ELSE&#013;&#010;    VARVALORCRED = 0;&#013;&#010;    VARVALORDEB  = NEW.VALORLCTO;&#013;&#010;  END IF;&#013;&#010;&#013;&#010;  UPDATE ECFMOVCONTAPARTEB&#013;&#010;     SET VLRCREDPARTEB = VLRCREDPARTEB + VARVALORCRED,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  + VARVALORDEB&#013;&#010;   WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;     AND TIPOIMPOSTO   = NEW.TIPOIMPOSTO&#013;&#010;     AND CODIGOCONTAB  = NEW.CODIGOCONTAB&#013;&#010;     AND DATASALDO     = NEW.DATALCTOFIS;&#013;&#010;&#013;&#010;  IF /*(ROW_COUNT = 0)*/NOT FOUND THEN&#013;&#010;    INSERT INTO ECFMOVCONTAPARTEB (CODIGOEMPRESA,&#013;&#010;                                   TIPOIMPOSTO,&#013;&#010;                                   CODIGOCONTAB,&#013;&#010;                                   DATASALDO,&#013;&#010;                                   VLRCREDPARTEA,&#013;&#010;                                   VLRDEBPARTEA,&#013;&#010;                                   VLRCREDPARTEB,&#013;&#010;                                   VLRDEBPARTEB)&#013;&#010;                           VALUES (NEW.CODIGOEMPRESA,&#013;&#010;                                   NEW.TIPOIMPOSTO,&#013;&#010;                                   NEW.CODIGOCONTAB,&#013;&#010;                                   NEW.DATALCTOFIS,&#013;&#010;                                   0,&#013;&#010;                                   0,&#013;&#010;                                   VARVALORCRED,&#013;&#010;                                   VARVALORDEB);&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="ecflctopartebsemreflexoauf" procedure_source="CREATE OR REPLACE FUNCTION public.ecflctopartebsemreflexoauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;VARVALORDEB NUMERIC(14,2);&#013;&#010;VARVALORCRED NUMERIC(14,2);&#013;&#010;BEGIN&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  IF (NEW.INDVALORLCTO = &apos;CR&apos;/*Credito*/) THEN&#013;&#010;    VARVALORCRED = NEW.VALORLCTO;&#013;&#010;    VARVALORDEB  = 0;&#013;&#010;  ELSE&#013;&#010;    VARVALORCRED = 0;&#013;&#010;    VARVALORDEB  = NEW.VALORLCTO;&#013;&#010;  END IF;&#013;&#010;&#013;&#010;  UPDATE ECFMOVCONTAPARTEB&#013;&#010;     SET VLRCREDPARTEB = VLRCREDPARTEB + VARVALORCRED,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  + VARVALORDEB&#013;&#010;   WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;     AND TIPOIMPOSTO   = NEW.TIPOIMPOSTO&#013;&#010;     AND CODIGOCONTAB  = NEW.CODIGOCONTAB&#013;&#010;     AND DATASALDO     = NEW.DATALCTOFIS;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="ecflctopartebsemreflexobdf" procedure_source="CREATE OR REPLACE FUNCTION public.ecflctopartebsemreflexobdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;VARVALORDEB Numeric(14,2);&#013;&#010;VARVALORCRED Numeric(14,2);&#013;&#010;VARVALORMOVIMENTO Numeric(14,2);&#013;&#010;BEGIN&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  IF (OLD.INDVALORLCTO = &apos;CR&apos;/*Credito*/) THEN&#013;&#010;    VARVALORCRED = OLD.VALORLCTO;&#013;&#010;    VARVALORDEB  = 0;&#013;&#010;  ELSE&#013;&#010;    VARVALORCRED = 0;&#013;&#010;    VARVALORDEB  = OLD.VALORLCTO;&#013;&#010;  END IF;&#013;&#010;&#013;&#010;  UPDATE ECFMOVCONTAPARTEB&#013;&#010;     SET VLRCREDPARTEB = VLRCREDPARTEB - VARVALORCRED,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  - VARVALORDEB&#013;&#010;   WHERE CODIGOEMPRESA = OLD.CODIGOEMPRESA&#013;&#010;     AND TIPOIMPOSTO   = OLD.TIPOIMPOSTO&#013;&#010;     AND CODIGOCONTAB  = OLD.CODIGOCONTAB&#013;&#010;     AND DATASALDO     = OLD.DATALCTOFIS;&#013;&#010;&#013;&#010;  SELECT M.VLRCREDPARTEA +&#013;&#010;         M.VLRDEBPARTEA  +&#013;&#010;         M.VLRCREDPARTEB +&#013;&#010;         M.VLRDEBPARTEB&#013;&#010;    FROM ECFMOVCONTAPARTEB M&#013;&#010;   WHERE M.CODIGOEMPRESA = OLD.CODIGOEMPRESA&#013;&#010;     AND M.TIPOIMPOSTO   = OLD.TIPOIMPOSTO&#013;&#010;     AND M.CODIGOCONTAB  = OLD.CODIGOCONTAB&#013;&#010;     AND M.DATASALDO     = OLD.DATALCTOFIS&#013;&#010;    INTO VARVALORMOVIMENTO;&#013;&#010;&#013;&#010;  IF (VARVALORMOVIMENTO = 0) THEN&#013;&#010;   DELETE FROM ECFMOVCONTAPARTEB D&#013;&#010;   WHERE D.CODIGOEMPRESA = OLD.CODIGOEMPRESA&#013;&#010;     AND D.TIPOIMPOSTO   = OLD.TIPOIMPOSTO&#013;&#010;     AND D.CODIGOCONTAB  = OLD.CODIGOCONTAB&#013;&#010;     AND D.DATASALDO     = OLD.DATALCTOFIS;&#013;&#010;  END IF;&#013;&#010;  RETURN OLD;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="ecflctopartebsemreflexobuf" procedure_source="CREATE OR REPLACE FUNCTION public.ecflctopartebsemreflexobuf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;VARVALORDEB NUMERIC(14,2);&#013;&#010;VARVALORCRED NUMERIC(14,2);&#013;&#010;BEGIN&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  IF (OLD.INDVALORLCTO = &apos;CR&apos;/*Credito*/) THEN&#013;&#010;    VARVALORCRED = OLD.VALORLCTO;&#013;&#010;    VARVALORDEB  = 0;&#013;&#010;  ELSE&#013;&#010;    VARVALORCRED = 0;&#013;&#010;    VARVALORDEB  = OLD.VALORLCTO;&#013;&#010;  END IF;&#013;&#010;&#013;&#010;  UPDATE ECFMOVCONTAPARTEB&#013;&#010;     SET VLRCREDPARTEB = VLRCREDPARTEB - VARVALORCRED,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  - VARVALORDEB&#013;&#010;   WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;     AND TIPOIMPOSTO   = NEW.TIPOIMPOSTO&#013;&#010;     AND CODIGOCONTAB  = NEW.CODIGOCONTAB&#013;&#010;     AND DATASALDO     = NEW.DATALCTOFIS;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="emailspessoafinanceiro" procedure_source="CREATE OR REPLACE FUNCTION public.emailspessoafinanceiro(pcodigo integer, OUT emails character varying)&#010; RETURNS character varying&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;email varchar(100);&#013;&#010;curdados cursor for (SELECT valor &#013;&#010;FROM pessoacontato &#013;&#010;WHERE tipocontato in (7,8,9) &#013;&#010;AND codigopessoafin = pcodigo &#013;&#010;ORDER BY tipocontato desc, codigopessoacontato);&#013;&#010;BEGIN &#013;&#010;  EMAILS = &apos;&apos;; &#013;&#010;  OPEN curdados;&#013;&#010;  &#013;&#010;  WHILE (1=1) LOOP&#013;&#010;BEGIN&#013;&#010;FETCH curdados INTO email;&#013;&#010;IF NOT FOUND /*(row_count = 0)*/ THEN &#013;&#010;EXIT; &#013;&#010;END IF;&#013;&#010;IF (EMAILS &lt;&gt; &apos;&apos;) THEN &#013;&#010;EMAILS = EMAILS || &apos;;&apos;;&#013;&#010;EMAILS = EMAILS || email; &#013;&#010;END IF;&#013;&#010;END;&#013;&#010;  END LOOP;&#013;&#010;  CLOSE curdados;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="emailspessoafinanceirorps" procedure_source="CREATE OR REPLACE FUNCTION public.emailspessoafinanceirorps(pcodigo integer, OUT emails character varying)&#010; RETURNS character varying&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;email varchar(100);&#013;&#010;curDados cursor for(&#013;&#010;SELECT Valor&#013;&#010;FROM PessoaContato&#013;&#010;WHERE TipoContato in (9)&#013;&#010;AND CodigoPessoaFin = PCODIGO&#013;&#010;ORDER BY CodigoPessoaContato);&#013;&#010;BEGIN&#013;&#010;EMAILS = &apos;&apos;;&#013;&#010;OPEN curDados;&#013;&#010;&#013;&#010;WHILE (1 = 1) LOOP&#013;&#010;BEGIN&#013;&#010;FETCH curDados INTO email;&#013;&#010;IF NOT FOUND /*(row_count = 0)*/ THEN&#013;&#010;exit;&#013;&#010;END IF;&#013;&#010;IF (EMAILS &lt;&gt; &apos;&apos;) THEN&#013;&#010;EMAILS = EMAILS || &apos;;&apos;;&#013;&#010;EMAILS = EMAILS || email;&#013;&#010;END IF;&#013;&#010;END;&#013;&#010;END LOOP;&#013;&#010;CLOSE curDados;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="entidadeligadaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.entidadeligadaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ENTIDADELIGADAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ENTIDADELIGADAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoentidadeligada, codigoestab, tipo, datainicialval, datafinalval, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoentidadeligada, NEW.codigoestab, NEW.tipo, NEW.datainicialval, NEW.datafinalval, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="entidadeligadaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.entidadeligadaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ENTIDADELIGADAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ENTIDADELIGADAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoentidadeligada, codigoestab, tipo, datainicialval, datafinalval, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoentidadeligada, OLD.codigoestab, OLD.tipo, OLD.datainicialval, OLD.datafinalval, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ENTIDADELIGADAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ENTIDADELIGADAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoentidadeligada, codigoestab, tipo, datainicialval, datafinalval, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoentidadeligada, NEW.codigoestab, NEW.tipo, NEW.datainicialval, NEW.datafinalval, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="entidadeligadabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.entidadeligadabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ENTIDADELIGADAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ENTIDADELIGADAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoentidadeligada, codigoestab, tipo, datainicialval, datafinalval, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoentidadeligada, OLD.codigoestab, OLD.tipo, OLD.datainicialval, OLD.datafinalval, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="escalaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.escalaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALAHS(SEQHISTORICO, OPERACAO, codigoescala, descrescala, cargahormensal, cargahorsemanal, cargahordiaria, tabelaferiado, codigotabferiado, horariovariavel, regimerevezppp, turno, codigoselecao, observescala) &#013;&#010;  VALUES (GEN, 1, NEW.codigoescala, NEW.descrescala, NEW.cargahormensal, NEW.cargahorsemanal, NEW.cargahordiaria, NEW.tabelaferiado, NEW.codigotabferiado, NEW.horariovariavel, NEW.regimerevezppp, NEW.turno, NEW.codigoselecao, NEW.observescala); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="escalaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.escalaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALAHS(SEQHISTORICO, OPERACAO, codigoescala, descrescala, cargahormensal, cargahorsemanal, cargahordiaria, tabelaferiado, codigotabferiado, horariovariavel, regimerevezppp, turno, codigoselecao, observescala) &#013;&#010;  VALUES (GEN, 2, OLD.codigoescala, OLD.descrescala, OLD.cargahormensal, OLD.cargahorsemanal, OLD.cargahordiaria, OLD.tabelaferiado, OLD.codigotabferiado, OLD.horariovariavel, OLD.regimerevezppp, OLD.turno, OLD.codigoselecao, OLD.observescala); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALAHS(SEQHISTORICO, OPERACAO, codigoescala, descrescala, cargahormensal, cargahorsemanal, cargahordiaria, tabelaferiado, codigotabferiado, horariovariavel, regimerevezppp, turno, codigoselecao, observescala) &#013;&#010;  VALUES (GEN, 3, NEW.codigoescala, NEW.descrescala, NEW.cargahormensal, NEW.cargahorsemanal, NEW.cargahordiaria, NEW.tabelaferiado, NEW.codigotabferiado, NEW.horariovariavel, NEW.regimerevezppp, NEW.turno, NEW.codigoselecao, NEW.observescala); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="escalabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.escalabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALAHS(SEQHISTORICO, OPERACAO, codigoescala, descrescala, cargahormensal, cargahorsemanal, cargahordiaria, tabelaferiado, codigotabferiado, horariovariavel, regimerevezppp, turno, codigoselecao, observescala) &#013;&#010;  VALUES (GEN, 4, OLD.codigoescala, OLD.descrescala, OLD.cargahormensal, OLD.cargahorsemanal, OLD.cargahordiaria, OLD.tabelaferiado, OLD.codigotabferiado, OLD.horariovariavel, OLD.regimerevezppp, OLD.turno, OLD.codigoselecao, OLD.observescala); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="escaladetalheaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.escaladetalheaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALADETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALADETALHEHS(SEQHISTORICO, OPERACAO, codigoescala, data, codigohorario) &#013;&#010;  VALUES (GEN, 1, NEW.codigoescala, NEW.data, NEW.codigohorario); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="escaladetalheauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.escaladetalheauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALADETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALADETALHEHS(SEQHISTORICO, OPERACAO, codigoescala, data, codigohorario) &#013;&#010;  VALUES (GEN, 2, OLD.codigoescala, OLD.data, OLD.codigohorario); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALADETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALADETALHEHS(SEQHISTORICO, OPERACAO, codigoescala, data, codigohorario) &#013;&#010;  VALUES (GEN, 3, NEW.codigoescala, NEW.data, NEW.codigohorario); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="escaladetalhebdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.escaladetalhebdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESCALADETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESCALADETALHEHS(SEQHISTORICO, OPERACAO, codigoescala, data, codigohorario) &#013;&#010;  VALUES (GEN, 4, OLD.codigoescala, OLD.data, OLD.codigohorario); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialcfgaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialcfgaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESOCIALCFGHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALCFGHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, classiftrib, indcooperativa, indconstrutora, codigocont, codigosocio, acordointmulta, tipoambiente, versaoleiauteesocial, obrigatoriedadeecd, desnonerafolha, numsiafi, regpropprevsoc, idtabrubr, matriz, gerouiniciais, entidadeeduc, emptrabtemp, pastaarquivos, emptrabtempreg, cnpjentfedresp, entfedresp, pastaarquivosreinf, utilizaroutorga, certifdigital, certifdigitalvenc, tipoalteracaoesocial, faseamento, tipoinsc, indopccp, indicativomeepp, prefixoidevento, inscrfederal, indtribfolhapis, bloqueioesocial, certificadocaminho, certificadosenha, indicativouniao, usarcalculopatronalesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datainicial, NEW.classiftrib, NEW.indcooperativa, NEW.indconstrutora, NEW.codigocont, NEW.codigosocio, NEW.acordointmulta, NEW.tipoambiente, NEW.versaoleiauteesocial, NEW.obrigatoriedadeecd, NEW.desnonerafolha, NEW.numsiafi, NEW.regpropprevsoc, NEW.idtabrubr, NEW.matriz, NEW.gerouiniciais, NEW.entidadeeduc, NEW.emptrabtemp, NEW.pastaarquivos, NEW.emptrabtempreg, NEW.cnpjentfedresp, NEW.entfedresp, NEW.pastaarquivosreinf, NEW.utilizaroutorga, NEW.certifdigital, NEW.certifdigitalvenc, NEW.tipoalteracaoesocial, NEW.faseamento, NEW.tipoinsc, NEW.indopccp, NEW.indicativomeepp, NEW.prefixoidevento, NEW.inscrfederal, NEW.indtribfolhapis, NEW.bloqueioesocial, NEW.certificadocaminho, NEW.certificadosenha, NEW.indicativouniao, NEW.usarcalculopatronalesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialcfgauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialcfgauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESOCIALCFGHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALCFGHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, classiftrib, indcooperativa, indconstrutora, codigocont, codigosocio, acordointmulta, tipoambiente, versaoleiauteesocial, obrigatoriedadeecd, desnonerafolha, numsiafi, regpropprevsoc, idtabrubr, matriz, gerouiniciais, entidadeeduc, emptrabtemp, pastaarquivos, emptrabtempreg, cnpjentfedresp, entfedresp, pastaarquivosreinf, utilizaroutorga, certifdigital, certifdigitalvenc, tipoalteracaoesocial, faseamento, tipoinsc, indopccp, indicativomeepp, prefixoidevento, inscrfederal, indtribfolhapis, bloqueioesocial, certificadocaminho, certificadosenha, indicativouniao, usarcalculopatronalesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datainicial, OLD.classiftrib, OLD.indcooperativa, OLD.indconstrutora, OLD.codigocont, OLD.codigosocio, OLD.acordointmulta, OLD.tipoambiente, OLD.versaoleiauteesocial, OLD.obrigatoriedadeecd, OLD.desnonerafolha, OLD.numsiafi, OLD.regpropprevsoc, OLD.idtabrubr, OLD.matriz, OLD.gerouiniciais, OLD.entidadeeduc, OLD.emptrabtemp, OLD.pastaarquivos, OLD.emptrabtempreg, OLD.cnpjentfedresp, OLD.entfedresp, OLD.pastaarquivosreinf, OLD.utilizaroutorga, OLD.certifdigital, OLD.certifdigitalvenc, OLD.tipoalteracaoesocial, OLD.faseamento, OLD.tipoinsc, OLD.indopccp, OLD.indicativomeepp, OLD.prefixoidevento, OLD.inscrfederal, OLD.indtribfolhapis, OLD.bloqueioesocial, OLD.certificadocaminho, OLD.certificadosenha, OLD.indicativouniao, OLD.usarcalculopatronalesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESOCIALCFGHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALCFGHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, classiftrib, indcooperativa, indconstrutora, codigocont, codigosocio, acordointmulta, tipoambiente, versaoleiauteesocial, obrigatoriedadeecd, desnonerafolha, numsiafi, regpropprevsoc, idtabrubr, matriz, gerouiniciais, entidadeeduc, emptrabtemp, pastaarquivos, emptrabtempreg, cnpjentfedresp, entfedresp, pastaarquivosreinf, utilizaroutorga, certifdigital, certifdigitalvenc, tipoalteracaoesocial, faseamento, tipoinsc, indopccp, indicativomeepp, prefixoidevento, inscrfederal, indtribfolhapis, bloqueioesocial, certificadocaminho, certificadosenha, indicativouniao, usarcalculopatronalesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datainicial, NEW.classiftrib, NEW.indcooperativa, NEW.indconstrutora, NEW.codigocont, NEW.codigosocio, NEW.acordointmulta, NEW.tipoambiente, NEW.versaoleiauteesocial, NEW.obrigatoriedadeecd, NEW.desnonerafolha, NEW.numsiafi, NEW.regpropprevsoc, NEW.idtabrubr, NEW.matriz, NEW.gerouiniciais, NEW.entidadeeduc, NEW.emptrabtemp, NEW.pastaarquivos, NEW.emptrabtempreg, NEW.cnpjentfedresp, NEW.entfedresp, NEW.pastaarquivosreinf, NEW.utilizaroutorga, NEW.certifdigital, NEW.certifdigitalvenc, NEW.tipoalteracaoesocial, NEW.faseamento, NEW.tipoinsc, NEW.indopccp, NEW.indicativomeepp, NEW.prefixoidevento, NEW.inscrfederal, NEW.indtribfolhapis, NEW.bloqueioesocial, NEW.certificadocaminho, NEW.certificadosenha, NEW.indicativouniao, NEW.usarcalculopatronalesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialcfgbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialcfgbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESOCIALCFGHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALCFGHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, classiftrib, indcooperativa, indconstrutora, codigocont, codigosocio, acordointmulta, tipoambiente, versaoleiauteesocial, obrigatoriedadeecd, desnonerafolha, numsiafi, regpropprevsoc, idtabrubr, matriz, gerouiniciais, entidadeeduc, emptrabtemp, pastaarquivos, emptrabtempreg, cnpjentfedresp, entfedresp, pastaarquivosreinf, utilizaroutorga, certifdigital, certifdigitalvenc, tipoalteracaoesocial, faseamento, tipoinsc, indopccp, indicativomeepp, prefixoidevento, inscrfederal, indtribfolhapis, bloqueioesocial, certificadocaminho, certificadosenha, indicativouniao, usarcalculopatronalesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datainicial, OLD.classiftrib, OLD.indcooperativa, OLD.indconstrutora, OLD.codigocont, OLD.codigosocio, OLD.acordointmulta, OLD.tipoambiente, OLD.versaoleiauteesocial, OLD.obrigatoriedadeecd, OLD.desnonerafolha, OLD.numsiafi, OLD.regpropprevsoc, OLD.idtabrubr, OLD.matriz, OLD.gerouiniciais, OLD.entidadeeduc, OLD.emptrabtemp, OLD.pastaarquivos, OLD.emptrabtempreg, OLD.cnpjentfedresp, OLD.entfedresp, OLD.pastaarquivosreinf, OLD.utilizaroutorga, OLD.certifdigital, OLD.certifdigitalvenc, OLD.tipoalteracaoesocial, OLD.faseamento, OLD.tipoinsc, OLD.indopccp, OLD.indicativomeepp, OLD.prefixoidevento, OLD.inscrfederal, OLD.indtribfolhapis, OLD.bloqueioesocial, OLD.certificadocaminho, OLD.certificadosenha, OLD.indicativouniao, OLD.usarcalculopatronalesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialeventoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialeventoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALEVENTOHS(SEQHISTORICO, OPERACAO, codigoeventoesocial, natureza, datainicial, datafinal, descricao) &#013;&#010;  VALUES (GEN, 1, NEW.codigoeventoesocial, NEW.natureza, NEW.datainicial, NEW.datafinal, NEW.descricao); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialeventoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialeventoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALEVENTOHS(SEQHISTORICO, OPERACAO, codigoeventoesocial, natureza, datainicial, datafinal, descricao) &#013;&#010;  VALUES (GEN, 2, OLD.codigoeventoesocial, OLD.natureza, OLD.datainicial, OLD.datafinal, OLD.descricao); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALEVENTOHS(SEQHISTORICO, OPERACAO, codigoeventoesocial, natureza, datainicial, datafinal, descricao) &#013;&#010;  VALUES (GEN, 3, NEW.codigoeventoesocial, NEW.natureza, NEW.datainicial, NEW.datafinal, NEW.descricao); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialeventobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialeventobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALEVENTOHS(SEQHISTORICO, OPERACAO, codigoeventoesocial, natureza, datainicial, datafinal, descricao) &#013;&#010;  VALUES (GEN, 4, OLD.codigoeventoesocial, OLD.natureza, OLD.datainicial, OLD.datafinal, OLD.descricao); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialisentasaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialisentasaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESOCIALISENTASHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALISENTASHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, siglamin, certificado, emissao, vencimento, numprotocolrenov, dataprotocolrenov, datadou, paginadou, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datainicial, NEW.siglamin, NEW.certificado, NEW.emissao, NEW.vencimento, NEW.numprotocolrenov, NEW.dataprotocolrenov, NEW.datadou, NEW.paginadou, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialisentasauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialisentasauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESOCIALISENTASHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALISENTASHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, siglamin, certificado, emissao, vencimento, numprotocolrenov, dataprotocolrenov, datadou, paginadou, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datainicial, OLD.siglamin, OLD.certificado, OLD.emissao, OLD.vencimento, OLD.numprotocolrenov, OLD.dataprotocolrenov, OLD.datadou, OLD.paginadou, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESOCIALISENTASHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALISENTASHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, siglamin, certificado, emissao, vencimento, numprotocolrenov, dataprotocolrenov, datadou, paginadou, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datainicial, NEW.siglamin, NEW.certificado, NEW.emissao, NEW.vencimento, NEW.numprotocolrenov, NEW.dataprotocolrenov, NEW.datadou, NEW.paginadou, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialisentasbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialisentasbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESOCIALISENTASHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALISENTASHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, siglamin, certificado, emissao, vencimento, numprotocolrenov, dataprotocolrenov, datadou, paginadou, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datainicial, OLD.siglamin, OLD.certificado, OLD.emissao, OLD.vencimento, OLD.numprotocolrenov, OLD.dataprotocolrenov, OLD.datadou, OLD.paginadou, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialproctrabaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialproctrabaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESOCIALPROCTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALPROCTRABHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, cpftrab, nometrab, dtnascto, origemproctrab, obsproctrab, dtsent, ufvara, codmunic, idvara, tpccp, dtccp, cnpjccp, respindireta, tpinsc, nrinsc, dtadmrespdir, matrespdir) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.nrproctrab, NEW.cpftrab, NEW.nometrab, NEW.dtnascto, NEW.origemproctrab, NEW.obsproctrab, NEW.dtsent, NEW.ufvara, NEW.codmunic, NEW.idvara, NEW.tpccp, NEW.dtccp, NEW.cnpjccp, NEW.respindireta, NEW.tpinsc, NEW.nrinsc, NEW.dtadmrespdir, NEW.matrespdir); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialproctrabauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialproctrabauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESOCIALPROCTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALPROCTRABHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, cpftrab, nometrab, dtnascto, origemproctrab, obsproctrab, dtsent, ufvara, codmunic, idvara, tpccp, dtccp, cnpjccp, respindireta, tpinsc, nrinsc, dtadmrespdir, matrespdir) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.nrproctrab, OLD.cpftrab, OLD.nometrab, OLD.dtnascto, OLD.origemproctrab, OLD.obsproctrab, OLD.dtsent, OLD.ufvara, OLD.codmunic, OLD.idvara, OLD.tpccp, OLD.dtccp, OLD.cnpjccp, OLD.respindireta, OLD.tpinsc, OLD.nrinsc, OLD.dtadmrespdir, OLD.matrespdir); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESOCIALPROCTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALPROCTRABHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, cpftrab, nometrab, dtnascto, origemproctrab, obsproctrab, dtsent, ufvara, codmunic, idvara, tpccp, dtccp, cnpjccp, respindireta, tpinsc, nrinsc, dtadmrespdir, matrespdir) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.nrproctrab, NEW.cpftrab, NEW.nometrab, NEW.dtnascto, NEW.origemproctrab, NEW.obsproctrab, NEW.dtsent, NEW.ufvara, NEW.codmunic, NEW.idvara, NEW.tpccp, NEW.dtccp, NEW.cnpjccp, NEW.respindireta, NEW.tpinsc, NEW.nrinsc, NEW.dtadmrespdir, NEW.matrespdir); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialproctrabbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialproctrabbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESOCIALPROCTRABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALPROCTRABHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, cpftrab, nometrab, dtnascto, origemproctrab, obsproctrab, dtsent, ufvara, codmunic, idvara, tpccp, dtccp, cnpjccp, respindireta, tpinsc, nrinsc, dtadmrespdir, matrespdir) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.nrproctrab, OLD.cpftrab, OLD.nometrab, OLD.dtnascto, OLD.origemproctrab, OLD.obsproctrab, OLD.dtsent, OLD.ufvara, OLD.codmunic, OLD.idvara, OLD.tpccp, OLD.dtccp, OLD.cnpjccp, OLD.respindireta, OLD.tpinsc, OLD.nrinsc, OLD.dtadmrespdir, OLD.matrespdir); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialtipoeventohistempaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialtipoeventohistempaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALTIPOEVENTOHISTEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALTIPOEVENTOHISTEMPHS(SEQHISTORICO, OPERACAO, tipoevento, tipoeventoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.tipoevento, NEW.tipoeventoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialtipoeventohistempauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialtipoeventohistempauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALTIPOEVENTOHISTEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALTIPOEVENTOHISTEMPHS(SEQHISTORICO, OPERACAO, tipoevento, tipoeventoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.tipoevento, OLD.tipoeventoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALTIPOEVENTOHISTEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALTIPOEVENTOHISTEMPHS(SEQHISTORICO, OPERACAO, tipoevento, tipoeventoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.tipoevento, NEW.tipoeventoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialtipoeventohistempbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialtipoeventohistempbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESOCIALTIPOEVENTOHISTEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESOCIALTIPOEVENTOHISTEMPHS(SEQHISTORICO, OPERACAO, tipoevento, tipoeventoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.tipoevento, OLD.tipoeventoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="esocialtransacaobdf" procedure_source="CREATE OR REPLACE FUNCTION public.esocialtransacaobdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="esocialtransacaobif" procedure_source="CREATE OR REPLACE FUNCTION public.esocialtransacaobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;IDEVENTOINSERIDO VARCHAR(50);&#013;&#010;INICIOID VARCHAR(50);&#013;&#010;FINALID INTEGER;&#013;&#010;VALORGENERATOR INTEGER;&#013;&#010;BEGIN&#013;&#010;  IDEVENTOINSERIDO := NEW.IDEVENTO;&#013;&#010;  IF ((NEW.ORIGEMDADO &lt;&gt; 3) AND (NEW.STATUS &lt;&gt; 0)) THEN&#013;&#010;    SELECT nextval(&apos;GENIDEVENTO&apos;) INTO VALORGENERATOR;&#013;&#010;&#013;&#010;    IF (VALORGENERATOR &gt;= 1000) THEN&#013;&#010;      ALTER SEQUENCE GENIDEVENTO RESTART WITH 1 MINVALUE 1;&#013;&#010;      SELECT nextval(&apos;GENIDEVENTO&apos;) INTO VALORGENERATOR;&#013;&#010;    END IF;&#013;&#010;&#013;&#010;    INICIOID := SUBSTRING(IDEVENTOINSERIDO FROM 1 FOR 32);&#013;&#010;    FINALID  := VALORGENERATOR;&#013;&#010;&#013;&#010;    IDEVENTOINSERIDO := INICIOID || CAST(LPAD(FINALID::TEXT, 4, &apos;0&apos;)  AS VARCHAR(4));&#013;&#010;&#013;&#010;  END IF;&#013;&#010;  NEW.IDEVENTO := IDEVENTOINSERIDO;&#013;&#010;  RETURN NEW;&#013;&#010;END&#013;&#010;&#013;&#010;$function$&#010;"/>
<ROW pro_key="estabaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.estabaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, nomeestab, nomeestabcompleto, nomefantasia, apelidoestab, codigotipolograd, enderecoestab, numenderestab, complenderestab, bairroenderestab, dataalterender, siglaestado, codigomunic, cependerestab, dddfone, numerofone, dddfax, numerofax, caixapostal, siglaestadocxp, cepcaixapostal, email, paginainternet, datainicioativ, dataencerativ, sociedadecontaparticipacao, inscricaoscp, tipoinscr, inscrfederal, cpfrespcno, suframa, codigonaturjurid, codigoativfederal, descrativfedestab, dataalterativfed, tiporegist, numeroregist, dataregist, observregist, inscrestad, codigoativestad, descrativestestab, inscrmunic, codigoativmunic, inscrimobiliaria, especieestab, inscrbancocentral, inscrsusep, descrativmunestab, porteempresa, inscrcvm, codigotabferiado, valornominalcotas, caepf, nomeauditor, cvmauditor, inscrfederalauditor, capitalsocial, inscrcaepf, inscrfederalprodrural, codigocategempresacliente, certificado, statussinczen, tipoalteracaoesocial, emaildpo, utilizafdtable, statussinczenii, distinguiritensmtzfl) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.datainicial, NEW.nomeestab, NEW.nomeestabcompleto, NEW.nomefantasia, NEW.apelidoestab, NEW.codigotipolograd, NEW.enderecoestab, NEW.numenderestab, NEW.complenderestab, NEW.bairroenderestab, NEW.dataalterender, NEW.siglaestado, NEW.codigomunic, NEW.cependerestab, NEW.dddfone, NEW.numerofone, NEW.dddfax, NEW.numerofax, NEW.caixapostal, NEW.siglaestadocxp, NEW.cepcaixapostal, NEW.email, NEW.paginainternet, NEW.datainicioativ, NEW.dataencerativ, NEW.sociedadecontaparticipacao, NEW.inscricaoscp, NEW.tipoinscr, NEW.inscrfederal, NEW.cpfrespcno, NEW.suframa, NEW.codigonaturjurid, NEW.codigoativfederal, NEW.descrativfedestab, NEW.dataalterativfed, NEW.tiporegist, NEW.numeroregist, NEW.dataregist, NEW.observregist, NEW.inscrestad, NEW.codigoativestad, NEW.descrativestestab, NEW.inscrmunic, NEW.codigoativmunic, NEW.inscrimobiliaria, NEW.especieestab, NEW.inscrbancocentral, NEW.inscrsusep, NEW.descrativmunestab, NEW.porteempresa, NEW.inscrcvm, NEW.codigotabferiado, NEW.valornominalcotas, NEW.caepf, NEW.nomeauditor, NEW.cvmauditor, NEW.inscrfederalauditor, NEW.capitalsocial, NEW.inscrcaepf, NEW.inscrfederalprodrural, NEW.codigocategempresacliente, NEW.certificado, NEW.statussinczen, NEW.tipoalteracaoesocial, NEW.emaildpo, NEW.utilizafdtable, NEW.statussinczenii, NEW.distinguiritensmtzfl); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="estabauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.estabauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, nomeestab, nomeestabcompleto, nomefantasia, apelidoestab, codigotipolograd, enderecoestab, numenderestab, complenderestab, bairroenderestab, dataalterender, siglaestado, codigomunic, cependerestab, dddfone, numerofone, dddfax, numerofax, caixapostal, siglaestadocxp, cepcaixapostal, email, paginainternet, datainicioativ, dataencerativ, sociedadecontaparticipacao, inscricaoscp, tipoinscr, inscrfederal, cpfrespcno, suframa, codigonaturjurid, codigoativfederal, descrativfedestab, dataalterativfed, tiporegist, numeroregist, dataregist, observregist, inscrestad, codigoativestad, descrativestestab, inscrmunic, codigoativmunic, inscrimobiliaria, especieestab, inscrbancocentral, inscrsusep, descrativmunestab, porteempresa, inscrcvm, codigotabferiado, valornominalcotas, caepf, nomeauditor, cvmauditor, inscrfederalauditor, capitalsocial, inscrcaepf, inscrfederalprodrural, codigocategempresacliente, certificado, statussinczen, tipoalteracaoesocial, emaildpo, utilizafdtable, statussinczenii, distinguiritensmtzfl) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.datainicial, OLD.nomeestab, OLD.nomeestabcompleto, OLD.nomefantasia, OLD.apelidoestab, OLD.codigotipolograd, OLD.enderecoestab, OLD.numenderestab, OLD.complenderestab, OLD.bairroenderestab, OLD.dataalterender, OLD.siglaestado, OLD.codigomunic, OLD.cependerestab, OLD.dddfone, OLD.numerofone, OLD.dddfax, OLD.numerofax, OLD.caixapostal, OLD.siglaestadocxp, OLD.cepcaixapostal, OLD.email, OLD.paginainternet, OLD.datainicioativ, OLD.dataencerativ, OLD.sociedadecontaparticipacao, OLD.inscricaoscp, OLD.tipoinscr, OLD.inscrfederal, OLD.cpfrespcno, OLD.suframa, OLD.codigonaturjurid, OLD.codigoativfederal, OLD.descrativfedestab, OLD.dataalterativfed, OLD.tiporegist, OLD.numeroregist, OLD.dataregist, OLD.observregist, OLD.inscrestad, OLD.codigoativestad, OLD.descrativestestab, OLD.inscrmunic, OLD.codigoativmunic, OLD.inscrimobiliaria, OLD.especieestab, OLD.inscrbancocentral, OLD.inscrsusep, OLD.descrativmunestab, OLD.porteempresa, OLD.inscrcvm, OLD.codigotabferiado, OLD.valornominalcotas, OLD.caepf, OLD.nomeauditor, OLD.cvmauditor, OLD.inscrfederalauditor, OLD.capitalsocial, OLD.inscrcaepf, OLD.inscrfederalprodrural, OLD.codigocategempresacliente, OLD.certificado, OLD.statussinczen, OLD.tipoalteracaoesocial, OLD.emaildpo, OLD.utilizafdtable, OLD.statussinczenii, OLD.distinguiritensmtzfl); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, nomeestab, nomeestabcompleto, nomefantasia, apelidoestab, codigotipolograd, enderecoestab, numenderestab, complenderestab, bairroenderestab, dataalterender, siglaestado, codigomunic, cependerestab, dddfone, numerofone, dddfax, numerofax, caixapostal, siglaestadocxp, cepcaixapostal, email, paginainternet, datainicioativ, dataencerativ, sociedadecontaparticipacao, inscricaoscp, tipoinscr, inscrfederal, cpfrespcno, suframa, codigonaturjurid, codigoativfederal, descrativfedestab, dataalterativfed, tiporegist, numeroregist, dataregist, observregist, inscrestad, codigoativestad, descrativestestab, inscrmunic, codigoativmunic, inscrimobiliaria, especieestab, inscrbancocentral, inscrsusep, descrativmunestab, porteempresa, inscrcvm, codigotabferiado, valornominalcotas, caepf, nomeauditor, cvmauditor, inscrfederalauditor, capitalsocial, inscrcaepf, inscrfederalprodrural, codigocategempresacliente, certificado, statussinczen, tipoalteracaoesocial, emaildpo, utilizafdtable, statussinczenii, distinguiritensmtzfl) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.datainicial, NEW.nomeestab, NEW.nomeestabcompleto, NEW.nomefantasia, NEW.apelidoestab, NEW.codigotipolograd, NEW.enderecoestab, NEW.numenderestab, NEW.complenderestab, NEW.bairroenderestab, NEW.dataalterender, NEW.siglaestado, NEW.codigomunic, NEW.cependerestab, NEW.dddfone, NEW.numerofone, NEW.dddfax, NEW.numerofax, NEW.caixapostal, NEW.siglaestadocxp, NEW.cepcaixapostal, NEW.email, NEW.paginainternet, NEW.datainicioativ, NEW.dataencerativ, NEW.sociedadecontaparticipacao, NEW.inscricaoscp, NEW.tipoinscr, NEW.inscrfederal, NEW.cpfrespcno, NEW.suframa, NEW.codigonaturjurid, NEW.codigoativfederal, NEW.descrativfedestab, NEW.dataalterativfed, NEW.tiporegist, NEW.numeroregist, NEW.dataregist, NEW.observregist, NEW.inscrestad, NEW.codigoativestad, NEW.descrativestestab, NEW.inscrmunic, NEW.codigoativmunic, NEW.inscrimobiliaria, NEW.especieestab, NEW.inscrbancocentral, NEW.inscrsusep, NEW.descrativmunestab, NEW.porteempresa, NEW.inscrcvm, NEW.codigotabferiado, NEW.valornominalcotas, NEW.caepf, NEW.nomeauditor, NEW.cvmauditor, NEW.inscrfederalauditor, NEW.capitalsocial, NEW.inscrcaepf, NEW.inscrfederalprodrural, NEW.codigocategempresacliente, NEW.certificado, NEW.statussinczen, NEW.tipoalteracaoesocial, NEW.emaildpo, NEW.utilizafdtable, NEW.statussinczenii, NEW.distinguiritensmtzfl); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="estabbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.estabbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ESTABHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTABHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, datainicial, nomeestab, nomeestabcompleto, nomefantasia, apelidoestab, codigotipolograd, enderecoestab, numenderestab, complenderestab, bairroenderestab, dataalterender, siglaestado, codigomunic, cependerestab, dddfone, numerofone, dddfax, numerofax, caixapostal, siglaestadocxp, cepcaixapostal, email, paginainternet, datainicioativ, dataencerativ, sociedadecontaparticipacao, inscricaoscp, tipoinscr, inscrfederal, cpfrespcno, suframa, codigonaturjurid, codigoativfederal, descrativfedestab, dataalterativfed, tiporegist, numeroregist, dataregist, observregist, inscrestad, codigoativestad, descrativestestab, inscrmunic, codigoativmunic, inscrimobiliaria, especieestab, inscrbancocentral, inscrsusep, descrativmunestab, porteempresa, inscrcvm, codigotabferiado, valornominalcotas, caepf, nomeauditor, cvmauditor, inscrfederalauditor, capitalsocial, inscrcaepf, inscrfederalprodrural, codigocategempresacliente, certificado, statussinczen, tipoalteracaoesocial, emaildpo, utilizafdtable, statussinczenii, distinguiritensmtzfl) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.datainicial, OLD.nomeestab, OLD.nomeestabcompleto, OLD.nomefantasia, OLD.apelidoestab, OLD.codigotipolograd, OLD.enderecoestab, OLD.numenderestab, OLD.complenderestab, OLD.bairroenderestab, OLD.dataalterender, OLD.siglaestado, OLD.codigomunic, OLD.cependerestab, OLD.dddfone, OLD.numerofone, OLD.dddfax, OLD.numerofax, OLD.caixapostal, OLD.siglaestadocxp, OLD.cepcaixapostal, OLD.email, OLD.paginainternet, OLD.datainicioativ, OLD.dataencerativ, OLD.sociedadecontaparticipacao, OLD.inscricaoscp, OLD.tipoinscr, OLD.inscrfederal, OLD.cpfrespcno, OLD.suframa, OLD.codigonaturjurid, OLD.codigoativfederal, OLD.descrativfedestab, OLD.dataalterativfed, OLD.tiporegist, OLD.numeroregist, OLD.dataregist, OLD.observregist, OLD.inscrestad, OLD.codigoativestad, OLD.descrativestestab, OLD.inscrmunic, OLD.codigoativmunic, OLD.inscrimobiliaria, OLD.especieestab, OLD.inscrbancocentral, OLD.inscrsusep, OLD.descrativmunestab, OLD.porteempresa, OLD.inscrcvm, OLD.codigotabferiado, OLD.valornominalcotas, OLD.caepf, OLD.nomeauditor, OLD.cvmauditor, OLD.inscrfederalauditor, OLD.capitalsocial, OLD.inscrcaepf, OLD.inscrfederalprodrural, OLD.codigocategempresacliente, OLD.certificado, OLD.statussinczen, OLD.tipoalteracaoesocial, OLD.emaildpo, OLD.utilizafdtable, OLD.statussinczenii, OLD.distinguiritensmtzfl); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="estadoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.estadoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESTADOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTADOHS(SEQHISTORICO, OPERACAO, siglaestado, nomeestado, estadobrasil, codigopais, aliqicmsinterna, aliqicmsexterna, codigosinief, regiaofiscal, codigoibge, regiaogeogr, mascinscrestad, utilizaativest, mascativestad, simplesfederal, aliqsimplesfederal) &#013;&#010;  VALUES (GEN, 1, NEW.siglaestado, NEW.nomeestado, NEW.estadobrasil, NEW.codigopais, NEW.aliqicmsinterna, NEW.aliqicmsexterna, NEW.codigosinief, NEW.regiaofiscal, NEW.codigoibge, NEW.regiaogeogr, NEW.mascinscrestad, NEW.utilizaativest, NEW.mascativestad, NEW.simplesfederal, NEW.aliqsimplesfederal); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="estadoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.estadoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESTADOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTADOHS(SEQHISTORICO, OPERACAO, siglaestado, nomeestado, estadobrasil, codigopais, aliqicmsinterna, aliqicmsexterna, codigosinief, regiaofiscal, codigoibge, regiaogeogr, mascinscrestad, utilizaativest, mascativestad, simplesfederal, aliqsimplesfederal) &#013;&#010;  VALUES (GEN, 2, OLD.siglaestado, OLD.nomeestado, OLD.estadobrasil, OLD.codigopais, OLD.aliqicmsinterna, OLD.aliqicmsexterna, OLD.codigosinief, OLD.regiaofiscal, OLD.codigoibge, OLD.regiaogeogr, OLD.mascinscrestad, OLD.utilizaativest, OLD.mascativestad, OLD.simplesfederal, OLD.aliqsimplesfederal); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESTADOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTADOHS(SEQHISTORICO, OPERACAO, siglaestado, nomeestado, estadobrasil, codigopais, aliqicmsinterna, aliqicmsexterna, codigosinief, regiaofiscal, codigoibge, regiaogeogr, mascinscrestad, utilizaativest, mascativestad, simplesfederal, aliqsimplesfederal) &#013;&#010;  VALUES (GEN, 3, NEW.siglaestado, NEW.nomeestado, NEW.estadobrasil, NEW.codigopais, NEW.aliqicmsinterna, NEW.aliqicmsexterna, NEW.codigosinief, NEW.regiaofiscal, NEW.codigoibge, NEW.regiaogeogr, NEW.mascinscrestad, NEW.utilizaativest, NEW.mascativestad, NEW.simplesfederal, NEW.aliqsimplesfederal); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="estadobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.estadobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ESTADOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ESTADOHS(SEQHISTORICO, OPERACAO, siglaestado, nomeestado, estadobrasil, codigopais, aliqicmsinterna, aliqicmsexterna, codigosinief, regiaofiscal, codigoibge, regiaogeogr, mascinscrestad, utilizaativest, mascativestad, simplesfederal, aliqsimplesfederal) &#013;&#010;  VALUES (GEN, 4, OLD.siglaestado, OLD.nomeestado, OLD.estadobrasil, OLD.codigopais, OLD.aliqicmsinterna, OLD.aliqicmsexterna, OLD.codigosinief, OLD.regiaofiscal, OLD.codigoibge, OLD.regiaogeogr, OLD.mascinscrestad, OLD.utilizaativest, OLD.mascativestad, OLD.simplesfederal, OLD.aliqsimplesfederal); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#010;DECLARE GEN INTEGER; &#010;BEGIN &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;EVENTOHS&apos;); &#010;&#010;  INSERT INTO EVENTOHS(SEQHISTORICO, OPERACAO, codigoevento, datainicial, descrevento, codigoproced, procedpersonalizado, codigoestrut, referevento, tipoevento, valorcalculo, valormin, valormax, camporescisao, codigoeventohomolognet, inssmensal, inss13, inssferias, inssmensalemp, inss13emp, inssferiasemp, fgtsmensal, fgts13, fgtsferias, irrfmensal, irrf13, irrfferias, pismensal, pis13, basesalfamilia, pisferias, irrflucro, eventoformarbases, basepensao, geraresocial, ordemcalculo, gravarevento, codigousuario, datahoralcto, origemdado, salfixo, notevento, salcontrib, classifrescisao, salhoraextra, saladic, salcomis, formainformedirf, localinformedirf, origemdadodirf, sal1tercferias, descrrendisentoout, remuncaged, remuneracao, remunrescisao, remunsegdesemppenant, calculoprof, codigoeventoesocial, incidesocialcp, incidesocialirrf, remunsegdesempult, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, dataconfer, codigoeventoesocialdomestmei, tetoremun) &#010;  VALUES (GEN, 1, NEW.codigoevento, NEW.datainicial, NEW.descrevento, NEW.codigoproced, NEW.procedpersonalizado, NEW.codigoestrut, NEW.referevento, NEW.tipoevento, NEW.valorcalculo, NEW.valormin, NEW.valormax, NEW.camporescisao, NEW.codigoeventohomolognet, NEW.inssmensal, NEW.inss13, NEW.inssferias, NEW.inssmensalemp, NEW.inss13emp, NEW.inssferiasemp, NEW.fgtsmensal, NEW.fgts13, NEW.fgtsferias, NEW.irrfmensal, NEW.irrf13, NEW.irrfferias, NEW.pismensal, NEW.pis13, NEW.basesalfamilia, NEW.pisferias, NEW.irrflucro, NEW.eventoformarbases, NEW.basepensao, NEW.geraresocial, NEW.ordemcalculo, NEW.gravarevento, NEW.codigousuario, NEW.datahoralcto, NEW.origemdado, NEW.salfixo, NEW.notevento, NEW.salcontrib, NEW.classifrescisao, NEW.salhoraextra, NEW.saladic, NEW.salcomis, NEW.formainformedirf, NEW.localinformedirf, NEW.origemdadodirf, NEW.sal1tercferias, NEW.descrrendisentoout, NEW.remuncaged, NEW.remuneracao, NEW.remunrescisao, NEW.remunsegdesemppenant, NEW.calculoprof, NEW.codigoeventoesocial, NEW.incidesocialcp, NEW.incidesocialirrf, NEW.remunsegdesempult, NEW.incidesocialfgts, NEW.incidesocialcontrsind, NEW.tipoalteracaoesocial, NEW.dataconfer, NEW.codigoeventoesocialdomestmei, NEW.tetoremun); &#010;&#010;RETURN NEW; &#010;END &#010;$function$&#010;"/>
<ROW pro_key="eventoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#010;DECLARE GEN INTEGER; &#010;BEGIN &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;EVENTOHS&apos;); &#010;&#010;  INSERT INTO EVENTOHS(SEQHISTORICO, OPERACAO, codigoevento, datainicial, descrevento, codigoproced, procedpersonalizado, codigoestrut, referevento, tipoevento, valorcalculo, valormin, valormax, camporescisao, codigoeventohomolognet, inssmensal, inss13, inssferias, inssmensalemp, inss13emp, inssferiasemp, fgtsmensal, fgts13, fgtsferias, irrfmensal, irrf13, irrfferias, pismensal, pis13, basesalfamilia, pisferias, irrflucro, eventoformarbases, basepensao, geraresocial, ordemcalculo, gravarevento, codigousuario, datahoralcto, origemdado, salfixo, notevento, salcontrib, classifrescisao, salhoraextra, saladic, salcomis, formainformedirf, localinformedirf, origemdadodirf, sal1tercferias, descrrendisentoout, remuncaged, remuneracao, remunrescisao, remunsegdesemppenant, calculoprof, codigoeventoesocial, incidesocialcp, incidesocialirrf, remunsegdesempult, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, dataconfer, codigoeventoesocialdomestmei, tetoremun) &#010;  VALUES (GEN, 2, OLD.codigoevento, OLD.datainicial, OLD.descrevento, OLD.codigoproced, OLD.procedpersonalizado, OLD.codigoestrut, OLD.referevento, OLD.tipoevento, OLD.valorcalculo, OLD.valormin, OLD.valormax, OLD.camporescisao, OLD.codigoeventohomolognet, OLD.inssmensal, OLD.inss13, OLD.inssferias, OLD.inssmensalemp, OLD.inss13emp, OLD.inssferiasemp, OLD.fgtsmensal, OLD.fgts13, OLD.fgtsferias, OLD.irrfmensal, OLD.irrf13, OLD.irrfferias, OLD.pismensal, OLD.pis13, OLD.basesalfamilia, OLD.pisferias, OLD.irrflucro, OLD.eventoformarbases, OLD.basepensao, OLD.geraresocial, OLD.ordemcalculo, OLD.gravarevento, OLD.codigousuario, OLD.datahoralcto, OLD.origemdado, OLD.salfixo, OLD.notevento, OLD.salcontrib, OLD.classifrescisao, OLD.salhoraextra, OLD.saladic, OLD.salcomis, OLD.formainformedirf, OLD.localinformedirf, OLD.origemdadodirf, OLD.sal1tercferias, OLD.descrrendisentoout, OLD.remuncaged, OLD.remuneracao, OLD.remunrescisao, OLD.remunsegdesemppenant, OLD.calculoprof, OLD.codigoeventoesocial, OLD.incidesocialcp, OLD.incidesocialirrf, OLD.remunsegdesempult, OLD.incidesocialfgts, OLD.incidesocialcontrsind, OLD.tipoalteracaoesocial, OLD.dataconfer, OLD.codigoeventoesocialdomestmei, OLD.tetoremun); &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;EVENTOHS&apos;); &#010;&#010;  INSERT INTO EVENTOHS(SEQHISTORICO, OPERACAO, codigoevento, datainicial, descrevento, codigoproced, procedpersonalizado, codigoestrut, referevento, tipoevento, valorcalculo, valormin, valormax, camporescisao, codigoeventohomolognet, inssmensal, inss13, inssferias, inssmensalemp, inss13emp, inssferiasemp, fgtsmensal, fgts13, fgtsferias, irrfmensal, irrf13, irrfferias, pismensal, pis13, basesalfamilia, pisferias, irrflucro, eventoformarbases, basepensao, geraresocial, ordemcalculo, gravarevento, codigousuario, datahoralcto, origemdado, salfixo, notevento, salcontrib, classifrescisao, salhoraextra, saladic, salcomis, formainformedirf, localinformedirf, origemdadodirf, sal1tercferias, descrrendisentoout, remuncaged, remuneracao, remunrescisao, remunsegdesemppenant, calculoprof, codigoeventoesocial, incidesocialcp, incidesocialirrf, remunsegdesempult, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, dataconfer, codigoeventoesocialdomestmei, tetoremun) &#010;  VALUES (GEN, 3, NEW.codigoevento, NEW.datainicial, NEW.descrevento, NEW.codigoproced, NEW.procedpersonalizado, NEW.codigoestrut, NEW.referevento, NEW.tipoevento, NEW.valorcalculo, NEW.valormin, NEW.valormax, NEW.camporescisao, NEW.codigoeventohomolognet, NEW.inssmensal, NEW.inss13, NEW.inssferias, NEW.inssmensalemp, NEW.inss13emp, NEW.inssferiasemp, NEW.fgtsmensal, NEW.fgts13, NEW.fgtsferias, NEW.irrfmensal, NEW.irrf13, NEW.irrfferias, NEW.pismensal, NEW.pis13, NEW.basesalfamilia, NEW.pisferias, NEW.irrflucro, NEW.eventoformarbases, NEW.basepensao, NEW.geraresocial, NEW.ordemcalculo, NEW.gravarevento, NEW.codigousuario, NEW.datahoralcto, NEW.origemdado, NEW.salfixo, NEW.notevento, NEW.salcontrib, NEW.classifrescisao, NEW.salhoraextra, NEW.saladic, NEW.salcomis, NEW.formainformedirf, NEW.localinformedirf, NEW.origemdadodirf, NEW.sal1tercferias, NEW.descrrendisentoout, NEW.remuncaged, NEW.remuneracao, NEW.remunrescisao, NEW.remunsegdesemppenant, NEW.calculoprof, NEW.codigoeventoesocial, NEW.incidesocialcp, NEW.incidesocialirrf, NEW.remunsegdesempult, NEW.incidesocialfgts, NEW.incidesocialcontrsind, NEW.tipoalteracaoesocial, NEW.dataconfer, NEW.codigoeventoesocialdomestmei, NEW.tetoremun); &#010;&#010;RETURN NEW; END &#010;$function$&#010;"/>
<ROW pro_key="eventobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#010;DECLARE GEN INTEGER; &#010;BEGIN &#010;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#010;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#010;  VALUES (GEN, &apos;EVENTOHS&apos;); &#010;&#010;  INSERT INTO EVENTOHS(SEQHISTORICO, OPERACAO, codigoevento, datainicial, descrevento, codigoproced, procedpersonalizado, codigoestrut, referevento, tipoevento, valorcalculo, valormin, valormax, camporescisao, codigoeventohomolognet, inssmensal, inss13, inssferias, inssmensalemp, inss13emp, inssferiasemp, fgtsmensal, fgts13, fgtsferias, irrfmensal, irrf13, irrfferias, pismensal, pis13, basesalfamilia, pisferias, irrflucro, eventoformarbases, basepensao, geraresocial, ordemcalculo, gravarevento, codigousuario, datahoralcto, origemdado, salfixo, notevento, salcontrib, classifrescisao, salhoraextra, saladic, salcomis, formainformedirf, localinformedirf, origemdadodirf, sal1tercferias, descrrendisentoout, remuncaged, remuneracao, remunrescisao, remunsegdesemppenant, calculoprof, codigoeventoesocial, incidesocialcp, incidesocialirrf, remunsegdesempult, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, dataconfer, codigoeventoesocialdomestmei, tetoremun) &#010;  VALUES (GEN, 4, OLD.codigoevento, OLD.datainicial, OLD.descrevento, OLD.codigoproced, OLD.procedpersonalizado, OLD.codigoestrut, OLD.referevento, OLD.tipoevento, OLD.valorcalculo, OLD.valormin, OLD.valormax, OLD.camporescisao, OLD.codigoeventohomolognet, OLD.inssmensal, OLD.inss13, OLD.inssferias, OLD.inssmensalemp, OLD.inss13emp, OLD.inssferiasemp, OLD.fgtsmensal, OLD.fgts13, OLD.fgtsferias, OLD.irrfmensal, OLD.irrf13, OLD.irrfferias, OLD.pismensal, OLD.pis13, OLD.basesalfamilia, OLD.pisferias, OLD.irrflucro, OLD.eventoformarbases, OLD.basepensao, OLD.geraresocial, OLD.ordemcalculo, OLD.gravarevento, OLD.codigousuario, OLD.datahoralcto, OLD.origemdado, OLD.salfixo, OLD.notevento, OLD.salcontrib, OLD.classifrescisao, OLD.salhoraextra, OLD.saladic, OLD.salcomis, OLD.formainformedirf, OLD.localinformedirf, OLD.origemdadodirf, OLD.sal1tercferias, OLD.descrrendisentoout, OLD.remuncaged, OLD.remuneracao, OLD.remunrescisao, OLD.remunsegdesemppenant, OLD.calculoprof, OLD.codigoeventoesocial, OLD.incidesocialcp, OLD.incidesocialirrf, OLD.remunsegdesempult, OLD.incidesocialfgts, OLD.incidesocialcontrsind, OLD.tipoalteracaoesocial, OLD.dataconfer, OLD.codigoeventoesocialdomestmei, OLD.tetoremun); &#010;&#010;RETURN OLD; END &#010;$function$&#010;"/>
<ROW pro_key="eventoempaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoempaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;EVENTOEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoevento, datainicial, status, rateiotipoaula) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoevento, NEW.datainicial, NEW.status, NEW.rateiotipoaula); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoempauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoempauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;EVENTOEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoevento, datainicial, status, rateiotipoaula) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoevento, OLD.datainicial, OLD.status, OLD.rateiotipoaula); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;EVENTOEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoevento, datainicial, status, rateiotipoaula) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoevento, NEW.datainicial, NEW.status, NEW.rateiotipoaula); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoempbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoempbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;EVENTOEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoevento, datainicial, status, rateiotipoaula) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoevento, OLD.datainicial, OLD.status, OLD.rateiotipoaula); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventohistoricoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventohistoricoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;EVENTOHISTORICOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOHISTORICOHS(SEQHISTORICO, OPERACAO, codigoevento, descrevento, datainicial, sequencia, tipoevento, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, codigoeventoesocialdomestmei, datahoralcto, codigousuario, eventomotivoalteracao, alteracaoesocial, tetoremun, codincpispasep) &#013;&#010;  VALUES (GEN, 1, NEW.codigoevento, NEW.descrevento, NEW.datainicial, NEW.sequencia, NEW.tipoevento, NEW.codigoeventoesocial, NEW.incidesocialcp, NEW.incidesocialirrf, NEW.incidesocialfgts, NEW.incidesocialcontrsind, NEW.tipoalteracaoesocial, NEW.codigoeventoesocialdomestmei, NEW.datahoralcto, NEW.codigousuario, NEW.eventomotivoalteracao, NEW.alteracaoesocial, NEW.tetoremun, NEW.codincpispasep); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventohistoricoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventohistoricoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;EVENTOHISTORICOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOHISTORICOHS(SEQHISTORICO, OPERACAO, codigoevento, descrevento, datainicial, sequencia, tipoevento, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, codigoeventoesocialdomestmei, datahoralcto, codigousuario, eventomotivoalteracao, alteracaoesocial, tetoremun, codincpispasep) &#013;&#010;  VALUES (GEN, 2, OLD.codigoevento, OLD.descrevento, OLD.datainicial, OLD.sequencia, OLD.tipoevento, OLD.codigoeventoesocial, OLD.incidesocialcp, OLD.incidesocialirrf, OLD.incidesocialfgts, OLD.incidesocialcontrsind, OLD.tipoalteracaoesocial, OLD.codigoeventoesocialdomestmei, OLD.datahoralcto, OLD.codigousuario, OLD.eventomotivoalteracao, OLD.alteracaoesocial, OLD.tetoremun, OLD.codincpispasep); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;EVENTOHISTORICOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOHISTORICOHS(SEQHISTORICO, OPERACAO, codigoevento, descrevento, datainicial, sequencia, tipoevento, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, codigoeventoesocialdomestmei, datahoralcto, codigousuario, eventomotivoalteracao, alteracaoesocial, tetoremun, codincpispasep) &#013;&#010;  VALUES (GEN, 3, NEW.codigoevento, NEW.descrevento, NEW.datainicial, NEW.sequencia, NEW.tipoevento, NEW.codigoeventoesocial, NEW.incidesocialcp, NEW.incidesocialirrf, NEW.incidesocialfgts, NEW.incidesocialcontrsind, NEW.tipoalteracaoesocial, NEW.codigoeventoesocialdomestmei, NEW.datahoralcto, NEW.codigousuario, NEW.eventomotivoalteracao, NEW.alteracaoesocial, NEW.tetoremun, NEW.codincpispasep); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventohistoricobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventohistoricobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;EVENTOHISTORICOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOHISTORICOHS(SEQHISTORICO, OPERACAO, codigoevento, descrevento, datainicial, sequencia, tipoevento, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoalteracaoesocial, codigoeventoesocialdomestmei, datahoralcto, codigousuario, eventomotivoalteracao, alteracaoesocial, tetoremun, codincpispasep) &#013;&#010;  VALUES (GEN, 4, OLD.codigoevento, OLD.descrevento, OLD.datainicial, OLD.sequencia, OLD.tipoevento, OLD.codigoeventoesocial, OLD.incidesocialcp, OLD.incidesocialirrf, OLD.incidesocialfgts, OLD.incidesocialcontrsind, OLD.tipoalteracaoesocial, OLD.codigoeventoesocialdomestmei, OLD.datahoralcto, OLD.codigousuario, OLD.eventomotivoalteracao, OLD.alteracaoesocial, OLD.tetoremun, OLD.codincpispasep); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoprocessoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoprocessoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;EVENTOPROCESSOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, tipoincidencia, codigoprocessojudadm, abrangenciadecisao, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datainicial, NEW.tipoincidencia, NEW.codigoprocessojudadm, NEW.abrangenciadecisao, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoprocessoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoprocessoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;EVENTOPROCESSOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, tipoincidencia, codigoprocessojudadm, abrangenciadecisao, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datainicial, OLD.tipoincidencia, OLD.codigoprocessojudadm, OLD.abrangenciadecisao, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;EVENTOPROCESSOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, tipoincidencia, codigoprocessojudadm, abrangenciadecisao, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datainicial, NEW.tipoincidencia, NEW.codigoprocessojudadm, NEW.abrangenciadecisao, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoprocessobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoprocessobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;EVENTOPROCESSOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, tipoincidencia, codigoprocessojudadm, abrangenciadecisao, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datainicial, OLD.tipoincidencia, OLD.codigoprocessojudadm, OLD.abrangenciadecisao, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoprocessodetaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoprocessodetaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;EVENTOPROCESSODETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSODETHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoincidencia, codigoprocessojudadm, codigoevento, incidmensal, incid13, incidferias, incidlucro, incidesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.tipoincidencia, NEW.codigoprocessojudadm, NEW.codigoevento, NEW.incidmensal, NEW.incid13, NEW.incidferias, NEW.incidlucro, NEW.incidesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoprocessodetauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoprocessodetauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;EVENTOPROCESSODETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSODETHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoincidencia, codigoprocessojudadm, codigoevento, incidmensal, incid13, incidferias, incidlucro, incidesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.tipoincidencia, OLD.codigoprocessojudadm, OLD.codigoevento, OLD.incidmensal, OLD.incid13, OLD.incidferias, OLD.incidlucro, OLD.incidesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;EVENTOPROCESSODETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSODETHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoincidencia, codigoprocessojudadm, codigoevento, incidmensal, incid13, incidferias, incidlucro, incidesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.tipoincidencia, NEW.codigoprocessojudadm, NEW.codigoevento, NEW.incidmensal, NEW.incid13, NEW.incidferias, NEW.incidlucro, NEW.incidesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="eventoprocessodetbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.eventoprocessodetbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;EVENTOPROCESSODETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO EVENTOPROCESSODETHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoincidencia, codigoprocessojudadm, codigoevento, incidmensal, incid13, incidferias, incidlucro, incidesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.tipoincidencia, OLD.codigoprocessojudadm, OLD.codigoevento, OLD.incidmensal, OLD.incid13, OLD.incidferias, OLD.incidlucro, OLD.incidesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="f_collatebr" procedure_source="CREATE OR REPLACE FUNCTION public.f_collatebr(text text)&#010; RETURNS text&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;BEGIN&#013;&#010;RETURN UPPER(TRANSLATE(TEXT, &apos;&#225;&#224;&#226;&#227;&#228;&#229;aaa&#193;&#194;&#195;&#196;&#197;AAA&#192;&#233;&#232;&#234;&#235;eeeeeEEE&#201;EE&#200;&#236;&#237;&#238;&#239;&#236;iii&#204;&#205;&#206;&#207;&#204;III&#243;&#244;&#245;&#246;ooo&#242;&#210;&#211;&#212;&#213;&#214;OOO&#249;&#250;&#251;&#252;uuuu&#217;&#218;&#219;&#220;UUUU&#231;&#199;&#241;&#209;&#253;&#221;&apos;,  &apos;aaaaaaaaaAAAAAAAAAeeeeeeeeeEEEEEEEiiiiiiiiIIIIIIIIooooooooOOOOOOOOuuuuuuuuUUUUUUUUcCnNyY&apos;));&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="faildelf" procedure_source="CREATE OR REPLACE FUNCTION public.faildelf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failinsf" procedure_source="CREATE OR REPLACE FUNCTION public.failinsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN NEW;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failupf" procedure_source="CREATE OR REPLACE FUNCTION public.failupf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN NEW;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failureef" procedure_source="CREATE OR REPLACE FUNCTION public.failureef()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failuref" procedure_source="CREATE OR REPLACE FUNCTION public.failuref()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failuregf" procedure_source="CREATE OR REPLACE FUNCTION public.failuregf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failurejf" procedure_source="CREATE OR REPLACE FUNCTION public.failurejf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failurepf" procedure_source="CREATE OR REPLACE FUNCTION public.failurepf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failurerf" procedure_source="CREATE OR REPLACE FUNCTION public.failurerf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failurevf" procedure_source="CREATE OR REPLACE FUNCTION public.failurevf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="failurevif" procedure_source="CREATE OR REPLACE FUNCTION public.failurevif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  RAISE EXCEPTION &apos;ERROR&apos;;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="formatardddfone" procedure_source="CREATE OR REPLACE FUNCTION public.formatardddfone(pnumerofone character varying, OUT ddd integer)&#010; RETURNS integer&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  IF (substring(PNUMEROFONE, 1, 1) = &apos;0&apos; AND (LENGTH(CAST(PNUMEROFONE AS TEXT)) = 9)) THEN &#010;    DDD = NULL;  &#010;  ELSE &#010;IF (SubStr(PNUMEROFONE, 1, 2) = &apos;00&apos;) THEN &#010;DDD = NULL;&#010;ELSE &#010;IF (LENGTH(CAST(PNUMEROFONE AS TEXT)) = 8) THEN &#010;DDD = NULL;&#010;ELSE &#010;IF ((SubStr(PNUMEROFONE, 1, 1) = &apos;0&apos;) AND (LENGTH(SubStr(CAST(PNUMEROFONE AS TEXT), 2, 2))) = &apos;2&apos;) THEN &#010;DDD = CAST(SubStr(PNUMEROFONE, 2, 2) AS integer);  &#010;ELSE &#010;IF ((LENGTH(PNUMEROFONE) = 9) AND (SubStr(PNUMEROFONE, 5, 5) &lt;&gt; &apos;.&apos;)) THEN &#010;DDD = CAST(SubStr(PNUMEROFONE, 1, 2) AS integer);  &#010;ELSE &#010;IF (SubStr(PNUMEROFONE, 1, 1) = &apos;(&apos;) THEN &#010;DDD = CAST(SubStr(PNUMEROFONE, 2, 2) AS integer);&#010;ELSE &#010;IF ((LENGTH(PNUMEROFONE) = 10) AND (SubStr(PNUMEROFONE, 1, 1) &lt;&gt; &apos;0&apos;) AND (position(&apos;.&apos; in PNUMEROFONE) = 0)) THEN &#010;DDD = CAST(SubStr(PNUMEROFONE, 1, 2) AS integer);  &#010;ELSE  &#010;DDD = NULL;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;  END IF;&#010;END;&#010;$function$&#010;"/>
<ROW pro_key="formatarnumerofone" procedure_source="CREATE OR REPLACE FUNCTION public.formatarnumerofone(pnumerofone character varying, OUT fone character)&#010; RETURNS character&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;FONE = NULL;&#010;&#010;IF (SUBSTR(PNUMEROFONE, 1, 1) &lt;&gt; &apos;(&apos; AND (SUBSTR(PNUMEROFONE, 6, 6) = &apos;.&apos;) AND (position(&apos;/&apos; IN PNUMEROFONE)=0)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 1, 5) || SUBSTR(PNUMEROFONE, 7, 10)  AS character varying);&#010;ELSE &#010;IF (SUBSTR(PNUMEROFONE, 1, 1) = &apos;(&apos; AND (SUBSTR(PNUMEROFONE, 11, 11) = &apos;.&apos;)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 6, 10) || SUBSTR(PNUMEROFONE, 12, 15)  AS character varying);&#010;ELSE &#010;IF (SUBSTR(PNUMEROFONE, 1, 1) = &apos;0&apos; AND (LENGTH(PNUMEROFONE) = 9)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 2, 9) AS character varying);   &#010;ELSE &#010;IF (SUBSTR(PNUMEROFONE, 1, 1) = &apos;0&apos; AND (LENGTH(PNUMEROFONE) = 10)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 3, 10) AS character varying);   &#010;ELSE &#010;IF (SUBSTR(PNUMEROFONE, 1, 1) = &apos;0&apos; AND (LENGTH(PNUMEROFONE) = 11)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 3, 11) AS character varying);  &#010;ELSE &#010;IF (SUBSTR(PNUMEROFONE, 1, 2) = &apos;00&apos;) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 3, LENGTH(PNUMEROFONE)) AS character varying);   &#010;ELSE &#010;IF ((LENGTH(PNUMEROFONE) = 9) AND (SUBSTR(PNUMEROFONE, 5, 5) &lt;&gt; &apos;.&apos;)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 3, 9) AS character varying);  &#010;ELSE &#010;IF ((LENGTH(PNUMEROFONE) = 9) AND (SUBSTR(PNUMEROFONE, 5, 5) = &apos;.&apos;)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 1, 4) || SUBSTR(PNUMEROFONE, 6, 9)  AS character varying);  &#010;ELSE &#010;IF (SUBSTR(PNUMEROFONE, 1, 1) = &apos;(&apos; AND (SUBSTR(PNUMEROFONE, 10, 10) = &apos;.&apos;)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 6, 9) || SUBSTR(PNUMEROFONE, 11, 14)  AS character varying);&#010;ELSE &#010;IF ((LENGTH(PNUMEROFONE) = 10) AND (SUBSTR(PNUMEROFONE, 1, 1) &lt;&gt; &apos;0&apos;)) THEN &#010;FONE = CAST(SUBSTR(PNUMEROFONE, 2, 10) AS character varying);&#010;ELSE &#010;FONE = CAST(PNUMEROFONE AS character varying);&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END;&#010;$function$&#010;"/>
<ROW pro_key="fprcaixaaif" procedure_source="CREATE OR REPLACE FUNCTION public.fprcaixaaif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  IF (new.TipoMovCaixa = 1) THEN&#010;    UPDATE FprContaSaldo&#010;       SET ValorDeb = ValorDeb + new.ValorCaixa&#010;     WHERE CODIGOESCRIT = new.CODIGOESCRIT&#010;       AND CodigoConta = new.CodigoConta&#010;       AND DataCaixa = new.DataCaixa;&#010;    IF /*(row_count = 0)*/NOT FOUND THEN&#010;        INSERT INTO FprContaSaldo (CODIGOESCRIT, CodigoConta,&#010;DataCaixa, ValorDeb, ValorCred)&#010; VALUES (new.CODIGOESCRIT, new.CodigoConta,&#010;new.DataCaixa, new.ValorCaixa,  0);&#010;    END IF;&#010;  END IF;&#010;  IF (new.TipoMovCaixa = -1) THEN&#010;    UPDATE FprContaSaldo&#010;       SET ValorCred = ValorCred + new.ValorCaixa&#010;     WHERE CODIGOESCRIT = new.CODIGOESCRIT&#010;       AND CodigoConta = new.CodigoConta&#010;       AND DataCaixa = new.DataCaixa;&#010;    IF /*(row_count = 0)*/NOT FOUND THEN&#010;        INSERT INTO FprContaSaldo (CODIGOESCRIT, CodigoConta,&#010;DataCaixa, ValorDeb, ValorCred)&#010; VALUES (new.CODIGOESCRIT, new.CodigoConta,&#010;new.DataCaixa, 0, new.ValorCaixa);&#010;    END IF;&#010;  END IF;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcaixaauf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcaixaauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE&#010;aAtualizaSaldo smallint;&#010;BEGIN&#010;  aAtualizaSaldo = 0;&#010;  IF (new.CODIGOESCRIT &lt;&gt; old.CODIGOESCRIT) THEN&#010;    aAtualizaSaldo = 1;&#010;  ELSE&#010;IF (new.DataCaixa &lt;&gt; old.DataCaixa) THEN&#010;aAtualizaSaldo = 1;&#010;ELSE&#010;IF (new.CodigoConta &lt;&gt; old.CodigoConta) THEN&#010;aAtualizaSaldo = 1;&#010;ELSE &#010;IF (new.ValorCaixa &lt;&gt; old.ValorCaixa) THEN&#010;aAtualizaSaldo = 1;&#010;ELSE&#010;IF (new.TipoMovCaixa &lt;&gt; old.TipoMovCaixa) THEN&#010;aAtualizaSaldo = 1;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;  END IF;&#010;  IF (aAtualizaSaldo = 1) THEN&#010;  IF (new.TipoMovCaixa = 1) THEN&#010;UPDATE FprContaSaldo&#010;         SET ValorDeb = ValorDeb + new.ValorCaixa&#010;WHERE CODIGOESCRIT = new.CODIGOESCRIT&#010;         AND CodigoConta = new.CodigoConta&#010;         AND DataCaixa = new.DataCaixa;&#010;  IF /*(row_count = 0)*/NOT FOUND THEN &#010;  INSERT INTO FprContaSaldo (CODIGOESCRIT,&#010;  CodigoConta,&#010;  DataCaixa,&#010;  ValorDeb,&#010;  ValorCred)&#010;  VALUES (new.CODIGOESCRIT,&#010;  new.CodigoConta,&#010;  new.DataCaixa,&#010;  new.ValorCaixa,&#010;  0);&#010;  END IF;&#010;  END IF; &#010;    IF (new.TipoMovCaixa = -1) THEN&#010;        UPDATE FprContaSaldo&#010;         SET ValorCred = ValorCred + new.ValorCaixa&#010;WHERE CODIGOESCRIT = new.CODIGOESCRIT&#010;         AND CodigoConta = new.CodigoConta&#010;         AND DataCaixa = new.DataCaixa;&#010;IF /*(row_count = 0)*/NOT FOUND THEN &#010;INSERT INTO FprContaSaldo (CODIGOESCRIT,&#010;CodigoConta,&#010;DataCaixa,&#010; ValorDeb,&#010;ValorCred)&#010;VALUES (new.CODIGOESCRIT,&#010;new.CodigoConta,&#010;new.DataCaixa,&#010;0,&#010;new.ValorCaixa);&#010;END IF;&#010;    END IF;&#010;  END IF;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcaixabdf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcaixabdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  IF (old.TipoMovCaixa = 1) THEN&#010;    UPDATE FprContaSaldo&#010;       SET ValorDeb = ValorDeb - old.ValorCaixa&#010;     WHERE CODIGOESCRIT = old.CODIGOESCRIT&#010;       AND CodigoConta = old.CodigoConta&#010;       AND DataCaixa = old.DataCaixa;&#010;  END IF;&#010;  IF (old.TipoMovCaixa = -1) THEN&#010;    UPDATE FprContaSaldo&#010;       SET ValorCred = ValorCred - old.ValorCaixa&#010;     WHERE CODIGOESCRIT = old.CODIGOESCRIT&#010;       AND CodigoConta = old.CodigoConta&#010;       AND DataCaixa = old.DataCaixa;&#010;  END IF;  &#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcaixabuf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcaixabuf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE&#010;aAtualizaSaldo smallint;&#010;BEGIN&#010;  aAtualizaSaldo = 0;&#010;  IF (new.CODIGOESCRIT &lt;&gt; old.CODIGOESCRIT) THEN&#010;    aAtualizaSaldo = 1;&#010;  ELSE &#010;IF (new.DataCaixa &lt;&gt; old.DataCaixa) THEN&#010;aAtualizaSaldo = 1;&#010;ELSE &#010;IF (new.CodigoConta &lt;&gt; old.CodigoConta) THEN&#010;aAtualizaSaldo = 1;&#010;ELSE &#010;IF (new.ValorCaixa &lt;&gt; old.ValorCaixa) THEN&#010;aAtualizaSaldo = 1;&#010;ELSE &#010;IF (new.TipoMovCaixa &lt;&gt; old.TipoMovCaixa) THEN&#010;aAtualizaSaldo = 1;&#010;END IF;&#010;END IF;&#010;END IF;&#010;END IF;&#010;  END IF;&#010;  IF (aAtualizaSaldo = 1) THEN&#010;    IF (old.TipoMovCaixa = 1) THEN&#010;UPDATE FprContaSaldo&#010;         SET ValorDeb = ValorDeb - old.ValorCaixa&#010;       WHERE CODIGOESCRIT = old.CODIGOESCRIT&#010;         AND CodigoConta = old.CodigoConta&#010;         AND DataCaixa = old.DataCaixa;&#010;    END IF;  &#010;    IF (old.TipoMovCaixa = -1) THEN&#010;UPDATE FprContaSaldo&#010;         SET ValorCred = ValorCred - old.ValorCaixa&#010;       WHERE CODIGOESCRIT = old.CODIGOESCRIT&#010;         AND CodigoConta = old.CodigoConta&#010;         AND DataCaixa = old.DataCaixa;&#010;    END IF;&#010;  END IF;  &#010;  RETURN NEW;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarauf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE &#010;SomaValorBaixa Numeric(15,2);&#010;ValorPagCab Numeric(15,2);&#010;BEGIN&#010;  SELECT COALESCE(SUM(FB.VALORBAIXA),0) INTO SomaValorBaixa &#010;   FROM FPRCONTAPAGARBAIXA FB&#010;  WHERE FB.codigoescrit = new.CODIGOESCRIT&#010;    AND FB.CODIGOPAGARCAB = new.CODIGOPAGARCAB;&#010;  SELECT COALESCE(FC.VALORPAGCAB,0) INTO ValorPagCab&#010;   FROM FPRCONTAPAGARCAB FC&#010;  WHERE FC.codigoescrit = new.CODIGOESCRIT&#010;    and FC.CODIGOPAGARCAB = new.CODIGOPAGARCAB;&#010;  IF (SomaValorBaixa &gt;= ValorPagCab) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF (SomaValorBaixa = 0) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarbaixaadf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarbaixaadf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE&#010;Valor Numeric(15,2);&#010;Saldo Numeric(15,2);&#010;Status Integer;&#010;SomaValorBaixa Numeric(15,2);&#010;ValorPagCab Numeric(15,2);&#010;BEGIN&#010; SELECT&#010;    CP.VALORPAG,&#010;    CP.SALDOPAG&#010;INTO Valor, Saldo&#010;  FROM FPRCONTAPAGAR CP&#010;  WHERE CP.CODIGOESCRIT = OLD.CODIGOESCRIT&#010;    AND CP.CODIGOPAGAR   = OLD.CODIGOPAGAR&#010;    AND CP.CODIGOPAGARCAB = OLD.CODIGOPAGARCAB;&#010;  IF (Saldo = 0) THEN  /* Esta Quitada (Status 3)*/&#010;    Status = 3;&#010;  ELSE&#010;IF (Valor = Saldo) THEN /* Esta Aberta (Status 1) */&#010;Status = 1;&#010;ELSE /* Esta Parcial (Status 2) */&#010;Status = 2;&#010;END IF;&#010;UPDATE FPRCONTAPAGAR SET  SITUACAOPAG = Status&#010;WHERE CODIGOESCRIT = OLD.CODIGOESCRIT&#010;AND CODIGOPAGAR = OLD.CODIGOPAGAR&#010;AND CODIGOPAGARCAB = OLD.CODIGOPAGARCAB;&#010;  END IF;&#010;  SELECT COALESCE(SUM(FB.VALORBAIXA), 0) INTO SomaValorBaixa&#010;FROM FPRCONTAPAGARBAIXA FB&#010;  WHERE FB.codigoescrit = old.CODIGOESCRIT&#010;    AND FB.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#010;  SELECT COALESCE(FC.VALORPAGCAB, 0) INTO ValorPagCab&#010;FROM FPRCONTAPAGARCAB FC&#010;  WHERE FC.codigoescrit = old.CODIGOESCRIT&#010;    AND FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#010;  IF (SomaValorBaixa &gt;= ValorPagCab) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#010;    WHERE FC.CODIGOESCRIT = old.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#010;    WHERE FC.CODIGOESCRIT = old.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF (SomaValorBaixa = 0) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#010;    WHERE FC.CODIGOESCRIT = old.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#010;  END IF;&#010;  RETURN OLD;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarbaixaaif" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarbaixaaif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE&#010;Valor Numeric(15,2);&#010;Saldo Numeric(15,2);&#010;Status Integer;&#010;SomaValorBaixa Numeric(15,2);&#010;ValorPagCab Numeric(15,2);&#010;BEGIN&#010; select&#010;    CP.VALORPAG,&#010;    CP.SALDOPAG&#010;INTO Valor, Saldo&#010;  FROM FPRCONTAPAGAR CP&#010;  WHERE CP.CODIGOESCRIT  = NEW.CODIGOESCRIT&#010;    AND CP.CODIGOPAGAR    = NEW.CODIGOPAGAR&#010;    AND CP.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  IF (Saldo = 0) THEN  /* Esta Quitada (Status 3)*/&#010;    Status = 3;&#010;  ELSE&#010;IF (Valor = Saldo) THEN /* Esta Aberta (Status 1) */&#010;Status = 1;&#010;ELSE /* Esta Parcial (Status 2) */&#010;Status = 2;&#010;END IF;&#010;    UPDATE FPRCONTAPAGAR set  SITUACAOPAG = Status&#010;WHERE CODIGOESCRIT = NEW.CODIGOESCRIT&#010;AND CODIGOPAGAR   = NEW.CODIGOPAGAR&#010;AND CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  SELECT COALESCE(SUM(FB.VALORBAIXA), 0) INTO SomaValorBaixa&#010;FROM FPRCONTAPAGARBAIXA FB&#010;  WHERE FB.codigoescrit = new.CODIGOESCRIT&#010;    AND FB.CODIGOPAGARCAB = new.CODIGOPAGARCAB;&#010;  SELECT COALESCE(FC.VALORPAGCAB, 0) INTO ValorPagCab&#010;FROM FPRCONTAPAGARCAB FC&#010;  WHERE FC.codigoescrit = new.CODIGOESCRIT&#010;    AND FC.CODIGOPAGARCAB = new.CODIGOPAGARCAB;&#010;  IF (SomaValorBaixa &gt;= ValorPagCab) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF (SomaValorBaixa = 0) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarbaixaauf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarbaixaauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE&#010;Valor Numeric(15,2);&#010;Saldo Numeric(15,2);&#010;Status Integer;&#010;SomaValorBaixa Numeric(15,2);&#010;ValorPagCab Numeric(15,2);&#010;BEGIN&#010; SELECT&#010;    CP.VALORPAG,&#010;    CP.SALDOPAG&#010;INTO Valor, Saldo&#010;  FROM FPRCONTAPAGAR CP&#010;  WHERE CP.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;    AND CP.CODIGOPAGAR   = NEW.CODIGOPAGAR&#010;    AND CP.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  IF (Saldo = 0) THEN  /* Esta Quitada (Status 3)*/&#010;    Status = 3;&#010;  ELSE&#010;IF (Valor = Saldo) THEN /* Esta Aberta (Status 1) */&#010;Status = 1;&#010;ELSE /* Esta Parcial (Status 2) */&#010;Status = 2;&#010;END IF;&#010;UPDATE FPRCONTAPAGAR SET  SITUACAOPAG = Status&#010;WHERE CODIGOESCRIT = NEW.CODIGOESCRIT&#010;AND CODIGOPAGAR   = NEW.CODIGOPAGAR&#010;AND CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  SELECT COALESCE(SUM(FB.VALORBAIXA), 0) INTO SomaValorBaixa&#010;FROM FPRCONTAPAGARBAIXA FB&#010;  WHERE FB.codigoescrit = new.CODIGOESCRIT&#010;    AND FB.CODIGOPAGARCAB = new.CODIGOPAGARCAB;&#010;  SELECT COALESCE(FC.VALORPAGCAB, 0) INTO ValorPagCab&#010;FROM FPRCONTAPAGARCAB FC&#010;  WHERE FC.codigoescrit = new.CODIGOESCRIT&#010;    AND FC.CODIGOPAGARCAB = new.CODIGOPAGARCAB;&#010;  IF (SomaValorBaixa &gt;= ValorPagCab) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      and FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  IF (SomaValorBaixa = 0) THEN&#010;    UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  END IF;&#010;  RETURN new;&#010;end; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarbaixabdf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarbaixabdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  UPDATE FPRCONTAPAGAR SET&#010;    SALDOPAG = SALDOPAG + OLD.VALORBAIXA&#010;  WHERE FPRCONTAPAGAR.CODIGOESCRIT = OLD.CODIGOESCRIT&#010;    AND FPRCONTAPAGAR.CODIGOPAGAR   = OLD.CODIGOPAGAR&#010;    AND CODIGOPAGARCAB = OLD.CODIGOPAGARCAB;&#010;  RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarbaixabif" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarbaixabif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  UPDATE FPRCONTAPAGAR SET&#010;    SALDOPAG = SALDOPAG - NEW.VALORBAIXA&#010;  WHERE FPRCONTAPAGAR.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;    AND FPRCONTAPAGAR.CODIGOPAGAR   = NEW.CODIGOPAGAR&#010;    AND FPRCONTAPAGAR.CODIGOPAGARCAB   = NEW.CODIGOPAGARCAB;&#010;  RETURN NEW;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarbaixabuf" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarbaixabuf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  UPDATE FPRCONTAPAGAR SET&#010;    SALDOPAG = SALDOPAG - (NEW.VALORBAIXA - OLD.VALORBAIXA)&#010;  WHERE FPRCONTAPAGAR.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;    AND FPRCONTAPAGAR.CODIGOPAGAR = NEW.CODIGOPAGAR&#010;    AND FPRCONTAPAGAR.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  RETURN NEW;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="fprcontapagarcabaif" procedure_source="CREATE OR REPLACE FUNCTION public.fprcontapagarcabaif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;  UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#010;    AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="funcaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOHS(SEQHISTORICO, OPERACAO, codigofuncao, datainicial, descrfuncao, cbo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigofuncao, NEW.datainicial, NEW.descrfuncao, NEW.cbo, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOHS(SEQHISTORICO, OPERACAO, codigofuncao, datainicial, descrfuncao, cbo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigofuncao, OLD.datainicial, OLD.descrfuncao, OLD.cbo, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOHS(SEQHISTORICO, OPERACAO, codigofuncao, datainicial, descrfuncao, cbo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigofuncao, NEW.datainicial, NEW.descrfuncao, NEW.cbo, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOHS(SEQHISTORICO, OPERACAO, codigofuncao, datainicial, descrfuncao, cbo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigofuncao, OLD.datainicial, OLD.descrfuncao, OLD.cbo, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcaoempresaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcaoempresaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofuncaorelat, codigofuncao, datainicial, status) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofuncaorelat, NEW.codigofuncao, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcaoempresaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcaoempresaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofuncaorelat, codigofuncao, datainicial, status) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofuncaorelat, OLD.codigofuncao, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofuncaorelat, codigofuncao, datainicial, status) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofuncaorelat, NEW.codigofuncao, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcaoempresabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcaoempresabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofuncaorelat, codigofuncao, datainicial, status) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofuncaorelat, OLD.codigofuncao, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcavisoprevioaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcavisoprevioaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporescisao, seq, complementar, codigocausa, tipoavisoprevio, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavinden, diasavreav, diasavprop, avisoprepropferias, avisopreprop13, diasestabil, diasgratif, diasavisotrab, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, enviouavisoprevioesocial, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, iniciocontagem, codigopercalculo, origemdado, datapagtorevisado, avosferiasind, observacao, percpensaojud, numcertobito, numproctrab, dataquarentena, quarentenaremunerada, tipoalteracaoesocial, avos13prop, remunaposdeslig, dtfimremun) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.tiporescisao, NEW.seq, NEW.complementar, NEW.codigocausa, NEW.tipoavisoprevio, NEW.codigosaque, NEW.tipoafastsefip, NEW.tipoafastcaged, NEW.tipoafastrais, NEW.codigomotdem, NEW.dataresc, NEW.dataavprevio, NEW.datapgtoresc, NEW.diastrab, NEW.diasavinden, NEW.diasavreav, NEW.diasavprop, NEW.avisoprepropferias, NEW.avisopreprop13, NEW.diasestabil, NEW.diasgratif, NEW.diasavisotrab, NEW.salfinal, NEW.fgtsmesant, NEW.avosferiasprop, NEW.codigofpas, NEW.codigooutemp, NEW.saldofgts, NEW.remmesant, NEW.remmesant13, NEW.valormesant, NEW.remmesantrecol, NEW.remmesant13recol, NEW.valormesantrecol, NEW.remmes, NEW.remmes13, NEW.valormes, NEW.remmesrecol, NEW.remmes13recol, NEW.valormesrecol, NEW.reminden, NEW.reminden13, NEW.valorinden, NEW.remindenrecol, NEW.reminden13recol, NEW.valorindenrecol, NEW.remmulta, NEW.valormulta, NEW.remmultarecol, NEW.valormultarecol, NEW.baseinss, NEW.deducao, NEW.salfamilia, NEW.fgtsrecol, NEW.valorinss, NEW.remunrescisao, NEW.remunsegdesempant, NEW.remunsegdesemppen, NEW.remunsegdesempult, NEW.remunult6meses, NEW.datacalcatrasogrfc, NEW.jammesant, NEW.jammes, NEW.jaminden, NEW.jammulta, NEW.datahomologresc, NEW.localhomologresc, NEW.reposicaovaga, NEW.enviouavisoprevioesocial, NEW.novoempregoavprevio, NEW.dispensaavprevio, NEW.cumpriujornadaintegralsemafast, NEW.jornadatrabsabcompensemafast, NEW.avisoprevio, NEW.codigousuario, NEW.datahoralcto, NEW.iniciocontagem, NEW.codigopercalculo, NEW.origemdado, NEW.datapagtorevisado, NEW.avosferiasind, NEW.observacao, NEW.percpensaojud, NEW.numcertobito, NEW.numproctrab, NEW.dataquarentena, NEW.quarentenaremunerada, NEW.tipoalteracaoesocial, NEW.avos13prop, NEW.remunaposdeslig, NEW.dtfimremun); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcavisoprevioauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcavisoprevioauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporescisao, seq, complementar, codigocausa, tipoavisoprevio, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavinden, diasavreav, diasavprop, avisoprepropferias, avisopreprop13, diasestabil, diasgratif, diasavisotrab, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, enviouavisoprevioesocial, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, iniciocontagem, codigopercalculo, origemdado, datapagtorevisado, avosferiasind, observacao, percpensaojud, numcertobito, numproctrab, dataquarentena, quarentenaremunerada, tipoalteracaoesocial, avos13prop, remunaposdeslig, dtfimremun) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.tiporescisao, OLD.seq, OLD.complementar, OLD.codigocausa, OLD.tipoavisoprevio, OLD.codigosaque, OLD.tipoafastsefip, OLD.tipoafastcaged, OLD.tipoafastrais, OLD.codigomotdem, OLD.dataresc, OLD.dataavprevio, OLD.datapgtoresc, OLD.diastrab, OLD.diasavinden, OLD.diasavreav, OLD.diasavprop, OLD.avisoprepropferias, OLD.avisopreprop13, OLD.diasestabil, OLD.diasgratif, OLD.diasavisotrab, OLD.salfinal, OLD.fgtsmesant, OLD.avosferiasprop, OLD.codigofpas, OLD.codigooutemp, OLD.saldofgts, OLD.remmesant, OLD.remmesant13, OLD.valormesant, OLD.remmesantrecol, OLD.remmesant13recol, OLD.valormesantrecol, OLD.remmes, OLD.remmes13, OLD.valormes, OLD.remmesrecol, OLD.remmes13recol, OLD.valormesrecol, OLD.reminden, OLD.reminden13, OLD.valorinden, OLD.remindenrecol, OLD.reminden13recol, OLD.valorindenrecol, OLD.remmulta, OLD.valormulta, OLD.remmultarecol, OLD.valormultarecol, OLD.baseinss, OLD.deducao, OLD.salfamilia, OLD.fgtsrecol, OLD.valorinss, OLD.remunrescisao, OLD.remunsegdesempant, OLD.remunsegdesemppen, OLD.remunsegdesempult, OLD.remunult6meses, OLD.datacalcatrasogrfc, OLD.jammesant, OLD.jammes, OLD.jaminden, OLD.jammulta, OLD.datahomologresc, OLD.localhomologresc, OLD.reposicaovaga, OLD.enviouavisoprevioesocial, OLD.novoempregoavprevio, OLD.dispensaavprevio, OLD.cumpriujornadaintegralsemafast, OLD.jornadatrabsabcompensemafast, OLD.avisoprevio, OLD.codigousuario, OLD.datahoralcto, OLD.iniciocontagem, OLD.codigopercalculo, OLD.origemdado, OLD.datapagtorevisado, OLD.avosferiasind, OLD.observacao, OLD.percpensaojud, OLD.numcertobito, OLD.numproctrab, OLD.dataquarentena, OLD.quarentenaremunerada, OLD.tipoalteracaoesocial, OLD.avos13prop, OLD.remunaposdeslig, OLD.dtfimremun); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporescisao, seq, complementar, codigocausa, tipoavisoprevio, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavinden, diasavreav, diasavprop, avisoprepropferias, avisopreprop13, diasestabil, diasgratif, diasavisotrab, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, enviouavisoprevioesocial, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, iniciocontagem, codigopercalculo, origemdado, datapagtorevisado, avosferiasind, observacao, percpensaojud, numcertobito, numproctrab, dataquarentena, quarentenaremunerada, tipoalteracaoesocial, avos13prop, remunaposdeslig, dtfimremun) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.tiporescisao, NEW.seq, NEW.complementar, NEW.codigocausa, NEW.tipoavisoprevio, NEW.codigosaque, NEW.tipoafastsefip, NEW.tipoafastcaged, NEW.tipoafastrais, NEW.codigomotdem, NEW.dataresc, NEW.dataavprevio, NEW.datapgtoresc, NEW.diastrab, NEW.diasavinden, NEW.diasavreav, NEW.diasavprop, NEW.avisoprepropferias, NEW.avisopreprop13, NEW.diasestabil, NEW.diasgratif, NEW.diasavisotrab, NEW.salfinal, NEW.fgtsmesant, NEW.avosferiasprop, NEW.codigofpas, NEW.codigooutemp, NEW.saldofgts, NEW.remmesant, NEW.remmesant13, NEW.valormesant, NEW.remmesantrecol, NEW.remmesant13recol, NEW.valormesantrecol, NEW.remmes, NEW.remmes13, NEW.valormes, NEW.remmesrecol, NEW.remmes13recol, NEW.valormesrecol, NEW.reminden, NEW.reminden13, NEW.valorinden, NEW.remindenrecol, NEW.reminden13recol, NEW.valorindenrecol, NEW.remmulta, NEW.valormulta, NEW.remmultarecol, NEW.valormultarecol, NEW.baseinss, NEW.deducao, NEW.salfamilia, NEW.fgtsrecol, NEW.valorinss, NEW.remunrescisao, NEW.remunsegdesempant, NEW.remunsegdesemppen, NEW.remunsegdesempult, NEW.remunult6meses, NEW.datacalcatrasogrfc, NEW.jammesant, NEW.jammes, NEW.jaminden, NEW.jammulta, NEW.datahomologresc, NEW.localhomologresc, NEW.reposicaovaga, NEW.enviouavisoprevioesocial, NEW.novoempregoavprevio, NEW.dispensaavprevio, NEW.cumpriujornadaintegralsemafast, NEW.jornadatrabsabcompensemafast, NEW.avisoprevio, NEW.codigousuario, NEW.datahoralcto, NEW.iniciocontagem, NEW.codigopercalculo, NEW.origemdado, NEW.datapagtorevisado, NEW.avosferiasind, NEW.observacao, NEW.percpensaojud, NEW.numcertobito, NEW.numproctrab, NEW.dataquarentena, NEW.quarentenaremunerada, NEW.tipoalteracaoesocial, NEW.avos13prop, NEW.remunaposdeslig, NEW.dtfimremun); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcavisopreviobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcavisopreviobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporescisao, seq, complementar, codigocausa, tipoavisoprevio, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavinden, diasavreav, diasavprop, avisoprepropferias, avisopreprop13, diasestabil, diasgratif, diasavisotrab, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, enviouavisoprevioesocial, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, iniciocontagem, codigopercalculo, origemdado, datapagtorevisado, avosferiasind, observacao, percpensaojud, numcertobito, numproctrab, dataquarentena, quarentenaremunerada, tipoalteracaoesocial, avos13prop, remunaposdeslig, dtfimremun) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.tiporescisao, OLD.seq, OLD.complementar, OLD.codigocausa, OLD.tipoavisoprevio, OLD.codigosaque, OLD.tipoafastsefip, OLD.tipoafastcaged, OLD.tipoafastrais, OLD.codigomotdem, OLD.dataresc, OLD.dataavprevio, OLD.datapgtoresc, OLD.diastrab, OLD.diasavinden, OLD.diasavreav, OLD.diasavprop, OLD.avisoprepropferias, OLD.avisopreprop13, OLD.diasestabil, OLD.diasgratif, OLD.diasavisotrab, OLD.salfinal, OLD.fgtsmesant, OLD.avosferiasprop, OLD.codigofpas, OLD.codigooutemp, OLD.saldofgts, OLD.remmesant, OLD.remmesant13, OLD.valormesant, OLD.remmesantrecol, OLD.remmesant13recol, OLD.valormesantrecol, OLD.remmes, OLD.remmes13, OLD.valormes, OLD.remmesrecol, OLD.remmes13recol, OLD.valormesrecol, OLD.reminden, OLD.reminden13, OLD.valorinden, OLD.remindenrecol, OLD.reminden13recol, OLD.valorindenrecol, OLD.remmulta, OLD.valormulta, OLD.remmultarecol, OLD.valormultarecol, OLD.baseinss, OLD.deducao, OLD.salfamilia, OLD.fgtsrecol, OLD.valorinss, OLD.remunrescisao, OLD.remunsegdesempant, OLD.remunsegdesemppen, OLD.remunsegdesempult, OLD.remunult6meses, OLD.datacalcatrasogrfc, OLD.jammesant, OLD.jammes, OLD.jaminden, OLD.jammulta, OLD.datahomologresc, OLD.localhomologresc, OLD.reposicaovaga, OLD.enviouavisoprevioesocial, OLD.novoempregoavprevio, OLD.dispensaavprevio, OLD.cumpriujornadaintegralsemafast, OLD.jornadatrabsabcompensemafast, OLD.avisoprevio, OLD.codigousuario, OLD.datahoralcto, OLD.iniciocontagem, OLD.codigopercalculo, OLD.origemdado, OLD.datapagtorevisado, OLD.avosferiasind, OLD.observacao, OLD.percpensaojud, OLD.numcertobito, OLD.numproctrab, OLD.dataquarentena, OLD.quarentenaremunerada, OLD.tipoalteracaoesocial, OLD.avos13prop, OLD.remunaposdeslig, OLD.dtfimremun); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcavisopreviocancaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcavisopreviocancaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOCANCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOCANCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, complementar, seq, dataavprevio, datacanc, observacao, motivocanc) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.complementar, NEW.seq, NEW.dataavprevio, NEW.datacanc, NEW.observacao, NEW.motivocanc); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcavisopreviocancauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcavisopreviocancauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOCANCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOCANCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, complementar, seq, dataavprevio, datacanc, observacao, motivocanc) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.complementar, OLD.seq, OLD.dataavprevio, OLD.datacanc, OLD.observacao, OLD.motivocanc); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOCANCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOCANCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, complementar, seq, dataavprevio, datacanc, observacao, motivocanc) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.complementar, NEW.seq, NEW.dataavprevio, NEW.datacanc, NEW.observacao, NEW.motivocanc); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcavisopreviocancbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcavisopreviocancbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCAVISOPREVIOCANCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCAVISOPREVIOCANCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, complementar, seq, dataavprevio, datacanc, observacao, motivocanc) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.complementar, OLD.seq, OLD.dataavprevio, OLD.datacanc, OLD.observacao, OLD.motivocanc); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccargoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccargoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigocargo, codigofuncao, motivoalteracao, codigomotivo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigocargo, NEW.codigofuncao, NEW.motivoalteracao, NEW.codigomotivo, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccargoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccargoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigocargo, codigofuncao, motivoalteracao, codigomotivo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigocargo, OLD.codigofuncao, OLD.motivoalteracao, OLD.codigomotivo, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigocargo, codigofuncao, motivoalteracao, codigomotivo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigocargo, NEW.codigofuncao, NEW.motivoalteracao, NEW.codigomotivo, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccargobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccargobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigocargo, codigofuncao, motivoalteracao, codigomotivo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigocargo, OLD.codigofuncao, OLD.motivoalteracao, OLD.codigomotivo, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccatsstaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccatsstaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCATSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCATSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datacat, numeroacidente, seq, tipocat, tipoacid, dataafast, horaafast, horaateacidtrab, houveobito, dataobito, registpolic, sitgeradoraacid, sitgeradoradoen, parteatingida, lateralidade, agencausadordoen, iniciatcat, obscat, localacid, codigooutemp, descrlocalacid, codigotipolograd, endereco, numero, complemento, bairro, cep, codigomunic, siglaestado, dataatendimento, horaatendimento, houveinternacao, afasttratamento, duracaotratamento, codigolesao, descricaocomplesao, diagnosticoprovavel, codigocid, obsatestadomedico, codigocorpoclinico, agencausadoracid, estabacid, ultimodiatrab, houveafast) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datacat, NEW.numeroacidente, NEW.seq, NEW.tipocat, NEW.tipoacid, NEW.dataafast, NEW.horaafast, NEW.horaateacidtrab, NEW.houveobito, NEW.dataobito, NEW.registpolic, NEW.sitgeradoraacid, NEW.sitgeradoradoen, NEW.parteatingida, NEW.lateralidade, NEW.agencausadordoen, NEW.iniciatcat, NEW.obscat, NEW.localacid, NEW.codigooutemp, NEW.descrlocalacid, NEW.codigotipolograd, NEW.endereco, NEW.numero, NEW.complemento, NEW.bairro, NEW.cep, NEW.codigomunic, NEW.siglaestado, NEW.dataatendimento, NEW.horaatendimento, NEW.houveinternacao, NEW.afasttratamento, NEW.duracaotratamento, NEW.codigolesao, NEW.descricaocomplesao, NEW.diagnosticoprovavel, NEW.codigocid, NEW.obsatestadomedico, NEW.codigocorpoclinico, NEW.agencausadoracid, NEW.estabacid, NEW.ultimodiatrab, NEW.houveafast); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccatsstauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccatsstauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCATSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCATSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datacat, numeroacidente, seq, tipocat, tipoacid, dataafast, horaafast, horaateacidtrab, houveobito, dataobito, registpolic, sitgeradoraacid, sitgeradoradoen, parteatingida, lateralidade, agencausadordoen, iniciatcat, obscat, localacid, codigooutemp, descrlocalacid, codigotipolograd, endereco, numero, complemento, bairro, cep, codigomunic, siglaestado, dataatendimento, horaatendimento, houveinternacao, afasttratamento, duracaotratamento, codigolesao, descricaocomplesao, diagnosticoprovavel, codigocid, obsatestadomedico, codigocorpoclinico, agencausadoracid, estabacid, ultimodiatrab, houveafast) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datacat, OLD.numeroacidente, OLD.seq, OLD.tipocat, OLD.tipoacid, OLD.dataafast, OLD.horaafast, OLD.horaateacidtrab, OLD.houveobito, OLD.dataobito, OLD.registpolic, OLD.sitgeradoraacid, OLD.sitgeradoradoen, OLD.parteatingida, OLD.lateralidade, OLD.agencausadordoen, OLD.iniciatcat, OLD.obscat, OLD.localacid, OLD.codigooutemp, OLD.descrlocalacid, OLD.codigotipolograd, OLD.endereco, OLD.numero, OLD.complemento, OLD.bairro, OLD.cep, OLD.codigomunic, OLD.siglaestado, OLD.dataatendimento, OLD.horaatendimento, OLD.houveinternacao, OLD.afasttratamento, OLD.duracaotratamento, OLD.codigolesao, OLD.descricaocomplesao, OLD.diagnosticoprovavel, OLD.codigocid, OLD.obsatestadomedico, OLD.codigocorpoclinico, OLD.agencausadoracid, OLD.estabacid, OLD.ultimodiatrab, OLD.houveafast); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCATSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCATSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datacat, numeroacidente, seq, tipocat, tipoacid, dataafast, horaafast, horaateacidtrab, houveobito, dataobito, registpolic, sitgeradoraacid, sitgeradoradoen, parteatingida, lateralidade, agencausadordoen, iniciatcat, obscat, localacid, codigooutemp, descrlocalacid, codigotipolograd, endereco, numero, complemento, bairro, cep, codigomunic, siglaestado, dataatendimento, horaatendimento, houveinternacao, afasttratamento, duracaotratamento, codigolesao, descricaocomplesao, diagnosticoprovavel, codigocid, obsatestadomedico, codigocorpoclinico, agencausadoracid, estabacid, ultimodiatrab, houveafast) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datacat, NEW.numeroacidente, NEW.seq, NEW.tipocat, NEW.tipoacid, NEW.dataafast, NEW.horaafast, NEW.horaateacidtrab, NEW.houveobito, NEW.dataobito, NEW.registpolic, NEW.sitgeradoraacid, NEW.sitgeradoradoen, NEW.parteatingida, NEW.lateralidade, NEW.agencausadordoen, NEW.iniciatcat, NEW.obscat, NEW.localacid, NEW.codigooutemp, NEW.descrlocalacid, NEW.codigotipolograd, NEW.endereco, NEW.numero, NEW.complemento, NEW.bairro, NEW.cep, NEW.codigomunic, NEW.siglaestado, NEW.dataatendimento, NEW.horaatendimento, NEW.houveinternacao, NEW.afasttratamento, NEW.duracaotratamento, NEW.codigolesao, NEW.descricaocomplesao, NEW.diagnosticoprovavel, NEW.codigocid, NEW.obsatestadomedico, NEW.codigocorpoclinico, NEW.agencausadoracid, NEW.estabacid, NEW.ultimodiatrab, NEW.houveafast); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccatsstbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccatsstbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCATSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCATSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datacat, numeroacidente, seq, tipocat, tipoacid, dataafast, horaafast, horaateacidtrab, houveobito, dataobito, registpolic, sitgeradoraacid, sitgeradoradoen, parteatingida, lateralidade, agencausadordoen, iniciatcat, obscat, localacid, codigooutemp, descrlocalacid, codigotipolograd, endereco, numero, complemento, bairro, cep, codigomunic, siglaestado, dataatendimento, horaatendimento, houveinternacao, afasttratamento, duracaotratamento, codigolesao, descricaocomplesao, diagnosticoprovavel, codigocid, obsatestadomedico, codigocorpoclinico, agencausadoracid, estabacid, ultimodiatrab, houveafast) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datacat, OLD.numeroacidente, OLD.seq, OLD.tipocat, OLD.tipoacid, OLD.dataafast, OLD.horaafast, OLD.horaateacidtrab, OLD.houveobito, OLD.dataobito, OLD.registpolic, OLD.sitgeradoraacid, OLD.sitgeradoradoen, OLD.parteatingida, OLD.lateralidade, OLD.agencausadordoen, OLD.iniciatcat, OLD.obscat, OLD.localacid, OLD.codigooutemp, OLD.descrlocalacid, OLD.codigotipolograd, OLD.endereco, OLD.numero, OLD.complemento, OLD.bairro, OLD.cep, OLD.codigomunic, OLD.siglaestado, OLD.dataatendimento, OLD.horaatendimento, OLD.houveinternacao, OLD.afasttratamento, OLD.duracaotratamento, OLD.codigolesao, OLD.descricaocomplesao, OLD.diagnosticoprovavel, OLD.codigocid, OLD.obsatestadomedico, OLD.codigocorpoclinico, OLD.agencausadoracid, OLD.estabacid, OLD.ultimodiatrab, OLD.houveafast); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrantaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrantaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRANTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRANTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigoagentenocivo, nomeemp, atividade, regimeativ, mesesdescons, seq, tipoinscr, inscrfederal, matricula, obs, formadeslig, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.datafinal, NEW.codigoagentenocivo, NEW.nomeemp, NEW.atividade, NEW.regimeativ, NEW.mesesdescons, NEW.seq, NEW.tipoinscr, NEW.inscrfederal, NEW.matricula, NEW.obs, NEW.formadeslig, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrantauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrantauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRANTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRANTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigoagentenocivo, nomeemp, atividade, regimeativ, mesesdescons, seq, tipoinscr, inscrfederal, matricula, obs, formadeslig, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.datafinal, OLD.codigoagentenocivo, OLD.nomeemp, OLD.atividade, OLD.regimeativ, OLD.mesesdescons, OLD.seq, OLD.tipoinscr, OLD.inscrfederal, OLD.matricula, OLD.obs, OLD.formadeslig, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRANTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRANTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigoagentenocivo, nomeemp, atividade, regimeativ, mesesdescons, seq, tipoinscr, inscrfederal, matricula, obs, formadeslig, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.datafinal, NEW.codigoagentenocivo, NEW.nomeemp, NEW.atividade, NEW.regimeativ, NEW.mesesdescons, NEW.seq, NEW.tipoinscr, NEW.inscrfederal, NEW.matricula, NEW.obs, NEW.formadeslig, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrantbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrantbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRANTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRANTHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigoagentenocivo, nomeemp, atividade, regimeativ, mesesdescons, seq, tipoinscr, inscrfederal, matricula, obs, formadeslig, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.datafinal, OLD.codigoagentenocivo, OLD.nomeemp, OLD.atividade, OLD.regimeativ, OLD.mesesdescons, OLD.seq, OLD.tipoinscr, OLD.inscrfederal, OLD.matricula, OLD.obs, OLD.formadeslig, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontratoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontratoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigofuncpessoa, codigotipocontr, dataadm, optantefgts, dataopcaofgts, contafgts, codigosit, dataaposent, tipovinculo, siglaestadominreg, codigocateg, categoria, codigotipofato, antecipdecimoterceiroeferias, categesocial, categorig, cnpjorigem, dataadmorig, matricorig, cnpjcednt, categorigcedido, matricced, recebe13sal, dtadmced, naturezaestagio, nivelestagio, infonus, recebeadto, percadto, perpgto, instituicaoensino, modopgto, tipoconta, codigobanco, areaatuacao, codigosupervisorestagio, numeroagencia, numeroconta, agenteintegracao, digitoconta, numerocartaovt, prevtermafastvt, emitecartao, perfiltareffa, chapeira, numeroinscrinss, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, emitircarne, inssfolha, datadem, datapgtoresccompl, codigoprocessojudadm, particpat, possuialvara, formacalculo, utilizaqcolabore, recebsegurodesemprego, statussinczen, diacontrexp, diaprorrogcontrexp, justprorrog, datatransfemp, codigousuario, datahoralcto, origemdado, indicatprimemp, regimetrab, regimeprev, motivocontrat, codigoempresasubst, tpinclcontr, codigofunccontrsubst, tipoinscrsefip, documentoscompletos, justcontr, codigoesocialtransacao, esocialsituacao, ordemcalculo, codigoempcontrataaprendiz, empcontrataprendiz, codigocursoform, indnumeroidentfiscal, numeroidentfiscal, clausulaassegresc, enviouprorrogesocial, tipoalteracaoesocial, matriculaesocial, tpinscr, frmtribut, cnpjentqual, cnpjprat, indaprend, statussinczenii) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigofuncpessoa, NEW.codigotipocontr, NEW.dataadm, NEW.optantefgts, NEW.dataopcaofgts, NEW.contafgts, NEW.codigosit, NEW.dataaposent, NEW.tipovinculo, NEW.siglaestadominreg, NEW.codigocateg, NEW.categoria, NEW.codigotipofato, NEW.antecipdecimoterceiroeferias, NEW.categesocial, NEW.categorig, NEW.cnpjorigem, NEW.dataadmorig, NEW.matricorig, NEW.cnpjcednt, NEW.categorigcedido, NEW.matricced, NEW.recebe13sal, NEW.dtadmced, NEW.naturezaestagio, NEW.nivelestagio, NEW.infonus, NEW.recebeadto, NEW.percadto, NEW.perpgto, NEW.instituicaoensino, NEW.modopgto, NEW.tipoconta, NEW.codigobanco, NEW.areaatuacao, NEW.codigosupervisorestagio, NEW.numeroagencia, NEW.numeroconta, NEW.agenteintegracao, NEW.digitoconta, NEW.numerocartaovt, NEW.prevtermafastvt, NEW.emitecartao, NEW.perfiltareffa, NEW.chapeira, NEW.numeroinscrinss, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigoimposto13, NEW.variacaoimposto13, NEW.emitircarne, NEW.inssfolha, NEW.datadem, NEW.datapgtoresccompl, NEW.codigoprocessojudadm, NEW.particpat, NEW.possuialvara, NEW.formacalculo, NEW.utilizaqcolabore, NEW.recebsegurodesemprego, NEW.statussinczen, NEW.diacontrexp, NEW.diaprorrogcontrexp, NEW.justprorrog, NEW.datatransfemp, NEW.codigousuario, NEW.datahoralcto, NEW.origemdado, NEW.indicatprimemp, NEW.regimetrab, NEW.regimeprev, NEW.motivocontrat, NEW.codigoempresasubst, NEW.tpinclcontr, NEW.codigofunccontrsubst, NEW.tipoinscrsefip, NEW.documentoscompletos, NEW.justcontr, NEW.codigoesocialtransacao, NEW.esocialsituacao, NEW.ordemcalculo, NEW.codigoempcontrataaprendiz, NEW.empcontrataprendiz, NEW.codigocursoform, NEW.indnumeroidentfiscal, NEW.numeroidentfiscal, NEW.clausulaassegresc, NEW.enviouprorrogesocial, NEW.tipoalteracaoesocial, NEW.matriculaesocial, NEW.tpinscr, NEW.frmtribut, NEW.cnpjentqual, NEW.cnpjprat, NEW.indaprend, NEW.statussinczenii); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontratoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontratoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigofuncpessoa, codigotipocontr, dataadm, optantefgts, dataopcaofgts, contafgts, codigosit, dataaposent, tipovinculo, siglaestadominreg, codigocateg, categoria, codigotipofato, antecipdecimoterceiroeferias, categesocial, categorig, cnpjorigem, dataadmorig, matricorig, cnpjcednt, categorigcedido, matricced, recebe13sal, dtadmced, naturezaestagio, nivelestagio, infonus, recebeadto, percadto, perpgto, instituicaoensino, modopgto, tipoconta, codigobanco, areaatuacao, codigosupervisorestagio, numeroagencia, numeroconta, agenteintegracao, digitoconta, numerocartaovt, prevtermafastvt, emitecartao, perfiltareffa, chapeira, numeroinscrinss, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, emitircarne, inssfolha, datadem, datapgtoresccompl, codigoprocessojudadm, particpat, possuialvara, formacalculo, utilizaqcolabore, recebsegurodesemprego, statussinczen, diacontrexp, diaprorrogcontrexp, justprorrog, datatransfemp, codigousuario, datahoralcto, origemdado, indicatprimemp, regimetrab, regimeprev, motivocontrat, codigoempresasubst, tpinclcontr, codigofunccontrsubst, tipoinscrsefip, documentoscompletos, justcontr, codigoesocialtransacao, esocialsituacao, ordemcalculo, codigoempcontrataaprendiz, empcontrataprendiz, codigocursoform, indnumeroidentfiscal, numeroidentfiscal, clausulaassegresc, enviouprorrogesocial, tipoalteracaoesocial, matriculaesocial, tpinscr, frmtribut, cnpjentqual, cnpjprat, indaprend, statussinczenii) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigofuncpessoa, OLD.codigotipocontr, OLD.dataadm, OLD.optantefgts, OLD.dataopcaofgts, OLD.contafgts, OLD.codigosit, OLD.dataaposent, OLD.tipovinculo, OLD.siglaestadominreg, OLD.codigocateg, OLD.categoria, OLD.codigotipofato, OLD.antecipdecimoterceiroeferias, OLD.categesocial, OLD.categorig, OLD.cnpjorigem, OLD.dataadmorig, OLD.matricorig, OLD.cnpjcednt, OLD.categorigcedido, OLD.matricced, OLD.recebe13sal, OLD.dtadmced, OLD.naturezaestagio, OLD.nivelestagio, OLD.infonus, OLD.recebeadto, OLD.percadto, OLD.perpgto, OLD.instituicaoensino, OLD.modopgto, OLD.tipoconta, OLD.codigobanco, OLD.areaatuacao, OLD.codigosupervisorestagio, OLD.numeroagencia, OLD.numeroconta, OLD.agenteintegracao, OLD.digitoconta, OLD.numerocartaovt, OLD.prevtermafastvt, OLD.emitecartao, OLD.perfiltareffa, OLD.chapeira, OLD.numeroinscrinss, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigoimposto13, OLD.variacaoimposto13, OLD.emitircarne, OLD.inssfolha, OLD.datadem, OLD.datapgtoresccompl, OLD.codigoprocessojudadm, OLD.particpat, OLD.possuialvara, OLD.formacalculo, OLD.utilizaqcolabore, OLD.recebsegurodesemprego, OLD.statussinczen, OLD.diacontrexp, OLD.diaprorrogcontrexp, OLD.justprorrog, OLD.datatransfemp, OLD.codigousuario, OLD.datahoralcto, OLD.origemdado, OLD.indicatprimemp, OLD.regimetrab, OLD.regimeprev, OLD.motivocontrat, OLD.codigoempresasubst, OLD.tpinclcontr, OLD.codigofunccontrsubst, OLD.tipoinscrsefip, OLD.documentoscompletos, OLD.justcontr, OLD.codigoesocialtransacao, OLD.esocialsituacao, OLD.ordemcalculo, OLD.codigoempcontrataaprendiz, OLD.empcontrataprendiz, OLD.codigocursoform, OLD.indnumeroidentfiscal, OLD.numeroidentfiscal, OLD.clausulaassegresc, OLD.enviouprorrogesocial, OLD.tipoalteracaoesocial, OLD.matriculaesocial, OLD.tpinscr, OLD.frmtribut, OLD.cnpjentqual, OLD.cnpjprat, OLD.indaprend, OLD.statussinczenii); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigofuncpessoa, codigotipocontr, dataadm, optantefgts, dataopcaofgts, contafgts, codigosit, dataaposent, tipovinculo, siglaestadominreg, codigocateg, categoria, codigotipofato, antecipdecimoterceiroeferias, categesocial, categorig, cnpjorigem, dataadmorig, matricorig, cnpjcednt, categorigcedido, matricced, recebe13sal, dtadmced, naturezaestagio, nivelestagio, infonus, recebeadto, percadto, perpgto, instituicaoensino, modopgto, tipoconta, codigobanco, areaatuacao, codigosupervisorestagio, numeroagencia, numeroconta, agenteintegracao, digitoconta, numerocartaovt, prevtermafastvt, emitecartao, perfiltareffa, chapeira, numeroinscrinss, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, emitircarne, inssfolha, datadem, datapgtoresccompl, codigoprocessojudadm, particpat, possuialvara, formacalculo, utilizaqcolabore, recebsegurodesemprego, statussinczen, diacontrexp, diaprorrogcontrexp, justprorrog, datatransfemp, codigousuario, datahoralcto, origemdado, indicatprimemp, regimetrab, regimeprev, motivocontrat, codigoempresasubst, tpinclcontr, codigofunccontrsubst, tipoinscrsefip, documentoscompletos, justcontr, codigoesocialtransacao, esocialsituacao, ordemcalculo, codigoempcontrataaprendiz, empcontrataprendiz, codigocursoform, indnumeroidentfiscal, numeroidentfiscal, clausulaassegresc, enviouprorrogesocial, tipoalteracaoesocial, matriculaesocial, tpinscr, frmtribut, cnpjentqual, cnpjprat, indaprend, statussinczenii) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigofuncpessoa, NEW.codigotipocontr, NEW.dataadm, NEW.optantefgts, NEW.dataopcaofgts, NEW.contafgts, NEW.codigosit, NEW.dataaposent, NEW.tipovinculo, NEW.siglaestadominreg, NEW.codigocateg, NEW.categoria, NEW.codigotipofato, NEW.antecipdecimoterceiroeferias, NEW.categesocial, NEW.categorig, NEW.cnpjorigem, NEW.dataadmorig, NEW.matricorig, NEW.cnpjcednt, NEW.categorigcedido, NEW.matricced, NEW.recebe13sal, NEW.dtadmced, NEW.naturezaestagio, NEW.nivelestagio, NEW.infonus, NEW.recebeadto, NEW.percadto, NEW.perpgto, NEW.instituicaoensino, NEW.modopgto, NEW.tipoconta, NEW.codigobanco, NEW.areaatuacao, NEW.codigosupervisorestagio, NEW.numeroagencia, NEW.numeroconta, NEW.agenteintegracao, NEW.digitoconta, NEW.numerocartaovt, NEW.prevtermafastvt, NEW.emitecartao, NEW.perfiltareffa, NEW.chapeira, NEW.numeroinscrinss, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigoimposto13, NEW.variacaoimposto13, NEW.emitircarne, NEW.inssfolha, NEW.datadem, NEW.datapgtoresccompl, NEW.codigoprocessojudadm, NEW.particpat, NEW.possuialvara, NEW.formacalculo, NEW.utilizaqcolabore, NEW.recebsegurodesemprego, NEW.statussinczen, NEW.diacontrexp, NEW.diaprorrogcontrexp, NEW.justprorrog, NEW.datatransfemp, NEW.codigousuario, NEW.datahoralcto, NEW.origemdado, NEW.indicatprimemp, NEW.regimetrab, NEW.regimeprev, NEW.motivocontrat, NEW.codigoempresasubst, NEW.tpinclcontr, NEW.codigofunccontrsubst, NEW.tipoinscrsefip, NEW.documentoscompletos, NEW.justcontr, NEW.codigoesocialtransacao, NEW.esocialsituacao, NEW.ordemcalculo, NEW.codigoempcontrataaprendiz, NEW.empcontrataprendiz, NEW.codigocursoform, NEW.indnumeroidentfiscal, NEW.numeroidentfiscal, NEW.clausulaassegresc, NEW.enviouprorrogesocial, NEW.tipoalteracaoesocial, NEW.matriculaesocial, NEW.tpinscr, NEW.frmtribut, NEW.cnpjentqual, NEW.cnpjprat, NEW.indaprend, NEW.statussinczenii); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontratobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontratobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigofuncpessoa, codigotipocontr, dataadm, optantefgts, dataopcaofgts, contafgts, codigosit, dataaposent, tipovinculo, siglaestadominreg, codigocateg, categoria, codigotipofato, antecipdecimoterceiroeferias, categesocial, categorig, cnpjorigem, dataadmorig, matricorig, cnpjcednt, categorigcedido, matricced, recebe13sal, dtadmced, naturezaestagio, nivelestagio, infonus, recebeadto, percadto, perpgto, instituicaoensino, modopgto, tipoconta, codigobanco, areaatuacao, codigosupervisorestagio, numeroagencia, numeroconta, agenteintegracao, digitoconta, numerocartaovt, prevtermafastvt, emitecartao, perfiltareffa, chapeira, numeroinscrinss, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, emitircarne, inssfolha, datadem, datapgtoresccompl, codigoprocessojudadm, particpat, possuialvara, formacalculo, utilizaqcolabore, recebsegurodesemprego, statussinczen, diacontrexp, diaprorrogcontrexp, justprorrog, datatransfemp, codigousuario, datahoralcto, origemdado, indicatprimemp, regimetrab, regimeprev, motivocontrat, codigoempresasubst, tpinclcontr, codigofunccontrsubst, tipoinscrsefip, documentoscompletos, justcontr, codigoesocialtransacao, esocialsituacao, ordemcalculo, codigoempcontrataaprendiz, empcontrataprendiz, codigocursoform, indnumeroidentfiscal, numeroidentfiscal, clausulaassegresc, enviouprorrogesocial, tipoalteracaoesocial, matriculaesocial, tpinscr, frmtribut, cnpjentqual, cnpjprat, indaprend, statussinczenii) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigofuncpessoa, OLD.codigotipocontr, OLD.dataadm, OLD.optantefgts, OLD.dataopcaofgts, OLD.contafgts, OLD.codigosit, OLD.dataaposent, OLD.tipovinculo, OLD.siglaestadominreg, OLD.codigocateg, OLD.categoria, OLD.codigotipofato, OLD.antecipdecimoterceiroeferias, OLD.categesocial, OLD.categorig, OLD.cnpjorigem, OLD.dataadmorig, OLD.matricorig, OLD.cnpjcednt, OLD.categorigcedido, OLD.matricced, OLD.recebe13sal, OLD.dtadmced, OLD.naturezaestagio, OLD.nivelestagio, OLD.infonus, OLD.recebeadto, OLD.percadto, OLD.perpgto, OLD.instituicaoensino, OLD.modopgto, OLD.tipoconta, OLD.codigobanco, OLD.areaatuacao, OLD.codigosupervisorestagio, OLD.numeroagencia, OLD.numeroconta, OLD.agenteintegracao, OLD.digitoconta, OLD.numerocartaovt, OLD.prevtermafastvt, OLD.emitecartao, OLD.perfiltareffa, OLD.chapeira, OLD.numeroinscrinss, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigoimposto13, OLD.variacaoimposto13, OLD.emitircarne, OLD.inssfolha, OLD.datadem, OLD.datapgtoresccompl, OLD.codigoprocessojudadm, OLD.particpat, OLD.possuialvara, OLD.formacalculo, OLD.utilizaqcolabore, OLD.recebsegurodesemprego, OLD.statussinczen, OLD.diacontrexp, OLD.diaprorrogcontrexp, OLD.justprorrog, OLD.datatransfemp, OLD.codigousuario, OLD.datahoralcto, OLD.origemdado, OLD.indicatprimemp, OLD.regimetrab, OLD.regimeprev, OLD.motivocontrat, OLD.codigoempresasubst, OLD.tpinclcontr, OLD.codigofunccontrsubst, OLD.tipoinscrsefip, OLD.documentoscompletos, OLD.justcontr, OLD.codigoesocialtransacao, OLD.esocialsituacao, OLD.ordemcalculo, OLD.codigoempcontrataaprendiz, OLD.empcontrataprendiz, OLD.codigocursoform, OLD.indnumeroidentfiscal, OLD.numeroidentfiscal, OLD.clausulaassegresc, OLD.enviouprorrogesocial, OLD.tipoalteracaoesocial, OLD.matriculaesocial, OLD.tpinscr, OLD.frmtribut, OLD.cnpjentqual, OLD.cnpjprat, OLD.indaprend, OLD.statussinczenii); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontratopreaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontratopreaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRATOPREHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOPREHS(SEQHISTORICO, OPERACAO, codigoempresa, cpffunc, nomefunc, datanasc, dataadm, matriculaesocial, codigofunccontr, codigotipocontr, categesocial, diacontrexp, diaprorrogcontrexp, codigotipofato, codigocargo, tiposalario, valorsal, integradofunccontrato, datacontrexp1, datacontrexp2, codigofunccontrix, termoconsentimento, codigosind, codigotabsal, codigoestrutsal, codigousuario, datahoralcto, origemdado, codigofuncpessoa, codigosit, antecsal, complsal, descrsal, salcarne, categoria, justprorrog, seq, datadem, origemadmissao, gerarpreliminar, idsyn) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.cpffunc, NEW.nomefunc, NEW.datanasc, NEW.dataadm, NEW.matriculaesocial, NEW.codigofunccontr, NEW.codigotipocontr, NEW.categesocial, NEW.diacontrexp, NEW.diaprorrogcontrexp, NEW.codigotipofato, NEW.codigocargo, NEW.tiposalario, NEW.valorsal, NEW.integradofunccontrato, NEW.datacontrexp1, NEW.datacontrexp2, NEW.codigofunccontrix, NEW.termoconsentimento, NEW.codigosind, NEW.codigotabsal, NEW.codigoestrutsal, NEW.codigousuario, NEW.datahoralcto, NEW.origemdado, NEW.codigofuncpessoa, NEW.codigosit, NEW.antecsal, NEW.complsal, NEW.descrsal, NEW.salcarne, NEW.categoria, NEW.justprorrog, NEW.seq, NEW.datadem, NEW.origemadmissao, NEW.gerarpreliminar, NEW.idsyn); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontratopreauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontratopreauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRATOPREHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOPREHS(SEQHISTORICO, OPERACAO, codigoempresa, cpffunc, nomefunc, datanasc, dataadm, matriculaesocial, codigofunccontr, codigotipocontr, categesocial, diacontrexp, diaprorrogcontrexp, codigotipofato, codigocargo, tiposalario, valorsal, integradofunccontrato, datacontrexp1, datacontrexp2, codigofunccontrix, termoconsentimento, codigosind, codigotabsal, codigoestrutsal, codigousuario, datahoralcto, origemdado, codigofuncpessoa, codigosit, antecsal, complsal, descrsal, salcarne, categoria, justprorrog, seq, datadem, origemadmissao, gerarpreliminar, idsyn) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.cpffunc, OLD.nomefunc, OLD.datanasc, OLD.dataadm, OLD.matriculaesocial, OLD.codigofunccontr, OLD.codigotipocontr, OLD.categesocial, OLD.diacontrexp, OLD.diaprorrogcontrexp, OLD.codigotipofato, OLD.codigocargo, OLD.tiposalario, OLD.valorsal, OLD.integradofunccontrato, OLD.datacontrexp1, OLD.datacontrexp2, OLD.codigofunccontrix, OLD.termoconsentimento, OLD.codigosind, OLD.codigotabsal, OLD.codigoestrutsal, OLD.codigousuario, OLD.datahoralcto, OLD.origemdado, OLD.codigofuncpessoa, OLD.codigosit, OLD.antecsal, OLD.complsal, OLD.descrsal, OLD.salcarne, OLD.categoria, OLD.justprorrog, OLD.seq, OLD.datadem, OLD.origemadmissao, OLD.gerarpreliminar, OLD.idsyn); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRATOPREHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOPREHS(SEQHISTORICO, OPERACAO, codigoempresa, cpffunc, nomefunc, datanasc, dataadm, matriculaesocial, codigofunccontr, codigotipocontr, categesocial, diacontrexp, diaprorrogcontrexp, codigotipofato, codigocargo, tiposalario, valorsal, integradofunccontrato, datacontrexp1, datacontrexp2, codigofunccontrix, termoconsentimento, codigosind, codigotabsal, codigoestrutsal, codigousuario, datahoralcto, origemdado, codigofuncpessoa, codigosit, antecsal, complsal, descrsal, salcarne, categoria, justprorrog, seq, datadem, origemadmissao, gerarpreliminar, idsyn) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.cpffunc, NEW.nomefunc, NEW.datanasc, NEW.dataadm, NEW.matriculaesocial, NEW.codigofunccontr, NEW.codigotipocontr, NEW.categesocial, NEW.diacontrexp, NEW.diaprorrogcontrexp, NEW.codigotipofato, NEW.codigocargo, NEW.tiposalario, NEW.valorsal, NEW.integradofunccontrato, NEW.datacontrexp1, NEW.datacontrexp2, NEW.codigofunccontrix, NEW.termoconsentimento, NEW.codigosind, NEW.codigotabsal, NEW.codigoestrutsal, NEW.codigousuario, NEW.datahoralcto, NEW.origemdado, NEW.codigofuncpessoa, NEW.codigosit, NEW.antecsal, NEW.complsal, NEW.descrsal, NEW.salcarne, NEW.categoria, NEW.justprorrog, NEW.seq, NEW.datadem, NEW.origemadmissao, NEW.gerarpreliminar, NEW.idsyn); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontratoprebdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontratoprebdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRATOPREHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRATOPREHS(SEQHISTORICO, OPERACAO, codigoempresa, cpffunc, nomefunc, datanasc, dataadm, matriculaesocial, codigofunccontr, codigotipocontr, categesocial, diacontrexp, diaprorrogcontrexp, codigotipofato, codigocargo, tiposalario, valorsal, integradofunccontrato, datacontrexp1, datacontrexp2, codigofunccontrix, termoconsentimento, codigosind, codigotabsal, codigoestrutsal, codigousuario, datahoralcto, origemdado, codigofuncpessoa, codigosit, antecsal, complsal, descrsal, salcarne, categoria, justprorrog, seq, datadem, origemadmissao, gerarpreliminar, idsyn) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.cpffunc, OLD.nomefunc, OLD.datanasc, OLD.dataadm, OLD.matriculaesocial, OLD.codigofunccontr, OLD.codigotipocontr, OLD.categesocial, OLD.diacontrexp, OLD.diaprorrogcontrexp, OLD.codigotipofato, OLD.codigocargo, OLD.tiposalario, OLD.valorsal, OLD.integradofunccontrato, OLD.datacontrexp1, OLD.datacontrexp2, OLD.codigofunccontrix, OLD.termoconsentimento, OLD.codigosind, OLD.codigotabsal, OLD.codigoestrutsal, OLD.codigousuario, OLD.datahoralcto, OLD.origemdado, OLD.codigofuncpessoa, OLD.codigosit, OLD.antecsal, OLD.complsal, OLD.descrsal, OLD.salcarne, OLD.categoria, OLD.justprorrog, OLD.seq, OLD.datadem, OLD.origemadmissao, OLD.gerarpreliminar, OLD.idsyn); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrintermitenteaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrintermitenteaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoconvocacao, dataconvocacao, horaconvocacao, datapagamento, situacao, datasituacao, horasituacao, status, indicativolocal, codigotipolograd, logradouro, numero, complemento, bairro, cep, siglaestado, codigomunic, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigoconvocacao, NEW.dataconvocacao, NEW.horaconvocacao, NEW.datapagamento, NEW.situacao, NEW.datasituacao, NEW.horasituacao, NEW.status, NEW.indicativolocal, NEW.codigotipolograd, NEW.logradouro, NEW.numero, NEW.complemento, NEW.bairro, NEW.cep, NEW.siglaestado, NEW.codigomunic, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrintermitenteauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrintermitenteauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoconvocacao, dataconvocacao, horaconvocacao, datapagamento, situacao, datasituacao, horasituacao, status, indicativolocal, codigotipolograd, logradouro, numero, complemento, bairro, cep, siglaestado, codigomunic, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigoconvocacao, OLD.dataconvocacao, OLD.horaconvocacao, OLD.datapagamento, OLD.situacao, OLD.datasituacao, OLD.horasituacao, OLD.status, OLD.indicativolocal, OLD.codigotipolograd, OLD.logradouro, OLD.numero, OLD.complemento, OLD.bairro, OLD.cep, OLD.siglaestado, OLD.codigomunic, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoconvocacao, dataconvocacao, horaconvocacao, datapagamento, situacao, datasituacao, horasituacao, status, indicativolocal, codigotipolograd, logradouro, numero, complemento, bairro, cep, siglaestado, codigomunic, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigoconvocacao, NEW.dataconvocacao, NEW.horaconvocacao, NEW.datapagamento, NEW.situacao, NEW.datasituacao, NEW.horasituacao, NEW.status, NEW.indicativolocal, NEW.codigotipolograd, NEW.logradouro, NEW.numero, NEW.complemento, NEW.bairro, NEW.cep, NEW.siglaestado, NEW.codigomunic, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrintermitentebdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrintermitentebdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRINTERMITENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRINTERMITENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoconvocacao, dataconvocacao, horaconvocacao, datapagamento, situacao, datasituacao, horasituacao, status, indicativolocal, codigotipolograd, logradouro, numero, complemento, bairro, cep, siglaestado, codigomunic, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigoconvocacao, OLD.dataconvocacao, OLD.horaconvocacao, OLD.datapagamento, OLD.situacao, OLD.datasituacao, OLD.horasituacao, OLD.status, OLD.indicativolocal, OLD.codigotipolograd, OLD.logradouro, OLD.numero, OLD.complemento, OLD.bairro, OLD.cep, OLD.siglaestado, OLD.codigomunic, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrreintegracaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrreintegracaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRREINTEGRACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRREINTEGRACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporeintegracao, numeroprocesso, leianistia, dataretorno, dataefeito, pagamentojuizo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.tiporeintegracao, NEW.numeroprocesso, NEW.leianistia, NEW.dataretorno, NEW.dataefeito, NEW.pagamentojuizo, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrreintegracaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrreintegracaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRREINTEGRACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRREINTEGRACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporeintegracao, numeroprocesso, leianistia, dataretorno, dataefeito, pagamentojuizo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.tiporeintegracao, OLD.numeroprocesso, OLD.leianistia, OLD.dataretorno, OLD.dataefeito, OLD.pagamentojuizo, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCONTRREINTEGRACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRREINTEGRACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporeintegracao, numeroprocesso, leianistia, dataretorno, dataefeito, pagamentojuizo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.tiporeintegracao, NEW.numeroprocesso, NEW.leianistia, NEW.dataretorno, NEW.dataefeito, NEW.pagamentojuizo, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funccontrreintegracaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funccontrreintegracaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCONTRREINTEGRACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCONTRREINTEGRACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, tiporeintegracao, numeroprocesso, leianistia, dataretorno, dataefeito, pagamentojuizo, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.tiporeintegracao, OLD.numeroprocesso, OLD.leianistia, OLD.dataretorno, OLD.dataefeito, OLD.pagamentojuizo, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcctpsaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcctpsaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCTPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCTPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, utilizacarteiradigital, numeroctps, datainicial, seriectps, siglaestadoctps, expedctps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.utilizacarteiradigital, NEW.numeroctps, NEW.datainicial, NEW.seriectps, NEW.siglaestadoctps, NEW.expedctps, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcctpsauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcctpsauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCTPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCTPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, utilizacarteiradigital, numeroctps, datainicial, seriectps, siglaestadoctps, expedctps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.utilizacarteiradigital, OLD.numeroctps, OLD.datainicial, OLD.seriectps, OLD.siglaestadoctps, OLD.expedctps, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCCTPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCTPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, utilizacarteiradigital, numeroctps, datainicial, seriectps, siglaestadoctps, expedctps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.utilizacarteiradigital, NEW.numeroctps, NEW.datainicial, NEW.seriectps, NEW.siglaestadoctps, NEW.expedctps, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcctpsbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcctpsbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCCTPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCCTPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, utilizacarteiradigital, numeroctps, datainicial, seriectps, siglaestadoctps, expedctps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.utilizacarteiradigital, OLD.numeroctps, OLD.datainicial, OLD.seriectps, OLD.siglaestadoctps, OLD.expedctps, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcescalaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcescalaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCESCALAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoescala, codigomotivo, regimejor, tipojornada, descrtipojornada, tipoadm, observacao, tempoparcial, tipoalteracaoesocial, executouutilitariojornada) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigoescala, NEW.codigomotivo, NEW.regimejor, NEW.tipojornada, NEW.descrtipojornada, NEW.tipoadm, NEW.observacao, NEW.tempoparcial, NEW.tipoalteracaoesocial, NEW.executouutilitariojornada); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcescalaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcescalaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCESCALAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoescala, codigomotivo, regimejor, tipojornada, descrtipojornada, tipoadm, observacao, tempoparcial, tipoalteracaoesocial, executouutilitariojornada) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigoescala, OLD.codigomotivo, OLD.regimejor, OLD.tipojornada, OLD.descrtipojornada, OLD.tipoadm, OLD.observacao, OLD.tempoparcial, OLD.tipoalteracaoesocial, OLD.executouutilitariojornada); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCESCALAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoescala, codigomotivo, regimejor, tipojornada, descrtipojornada, tipoadm, observacao, tempoparcial, tipoalteracaoesocial, executouutilitariojornada) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigoescala, NEW.codigomotivo, NEW.regimejor, NEW.tipojornada, NEW.descrtipojornada, NEW.tipoadm, NEW.observacao, NEW.tempoparcial, NEW.tipoalteracaoesocial, NEW.executouutilitariojornada); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcescalabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcescalabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCESCALAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCESCALAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoescala, codigomotivo, regimejor, tipojornada, descrtipojornada, tipoadm, observacao, tempoparcial, tipoalteracaoesocial, executouutilitariojornada) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigoescala, OLD.codigomotivo, OLD.regimejor, OLD.tipojornada, OLD.descrtipojornada, OLD.tipoadm, OLD.observacao, OLD.tempoparcial, OLD.tipoalteracaoesocial, OLD.executouutilitariojornada); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcexamemedaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcexamemedaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCEXAMEMEDHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, datarealizado, codigoexametoxicologico, codigooutempemp, codigonaturexame, examersppp, resultexame, alterexame, origemexame, responsavel, codigoempresp, codigofunccontrresp, codigoterc, autorizou, codigocorpoclinico, resultadoaso, cnpjlab) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigoexamemed, NEW.dataexame, NEW.datarealizado, NEW.codigoexametoxicologico, NEW.codigooutempemp, NEW.codigonaturexame, NEW.examersppp, NEW.resultexame, NEW.alterexame, NEW.origemexame, NEW.responsavel, NEW.codigoempresp, NEW.codigofunccontrresp, NEW.codigoterc, NEW.autorizou, NEW.codigocorpoclinico, NEW.resultadoaso, NEW.cnpjlab); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcexamemedauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcexamemedauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCEXAMEMEDHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, datarealizado, codigoexametoxicologico, codigooutempemp, codigonaturexame, examersppp, resultexame, alterexame, origemexame, responsavel, codigoempresp, codigofunccontrresp, codigoterc, autorizou, codigocorpoclinico, resultadoaso, cnpjlab) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigoexamemed, OLD.dataexame, OLD.datarealizado, OLD.codigoexametoxicologico, OLD.codigooutempemp, OLD.codigonaturexame, OLD.examersppp, OLD.resultexame, OLD.alterexame, OLD.origemexame, OLD.responsavel, OLD.codigoempresp, OLD.codigofunccontrresp, OLD.codigoterc, OLD.autorizou, OLD.codigocorpoclinico, OLD.resultadoaso, OLD.cnpjlab); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCEXAMEMEDHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, datarealizado, codigoexametoxicologico, codigooutempemp, codigonaturexame, examersppp, resultexame, alterexame, origemexame, responsavel, codigoempresp, codigofunccontrresp, codigoterc, autorizou, codigocorpoclinico, resultadoaso, cnpjlab) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigoexamemed, NEW.dataexame, NEW.datarealizado, NEW.codigoexametoxicologico, NEW.codigooutempemp, NEW.codigonaturexame, NEW.examersppp, NEW.resultexame, NEW.alterexame, NEW.origemexame, NEW.responsavel, NEW.codigoempresp, NEW.codigofunccontrresp, NEW.codigoterc, NEW.autorizou, NEW.codigocorpoclinico, NEW.resultadoaso, NEW.cnpjlab); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcexamemedbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcexamemedbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCEXAMEMEDHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, datarealizado, codigoexametoxicologico, codigooutempemp, codigonaturexame, examersppp, resultexame, alterexame, origemexame, responsavel, codigoempresp, codigofunccontrresp, codigoterc, autorizou, codigocorpoclinico, resultadoaso, cnpjlab) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigoexamemed, OLD.dataexame, OLD.datarealizado, OLD.codigoexametoxicologico, OLD.codigooutempemp, OLD.codigonaturexame, OLD.examersppp, OLD.resultexame, OLD.alterexame, OLD.origemexame, OLD.responsavel, OLD.codigoempresp, OLD.codigofunccontrresp, OLD.codigoterc, OLD.autorizou, OLD.codigocorpoclinico, OLD.resultadoaso, OLD.cnpjlab); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcexamemedcomplemaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcexamemedcomplemaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCEXAMEMEDCOMPLEMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDCOMPLEMHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, seqexame, datarealizacaoexame, codigoprocedimentosdiag, obsexamecomplem, ordexame, resultadoexamecomplem) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigoexamemed, NEW.dataexame, NEW.seqexame, NEW.datarealizacaoexame, NEW.codigoprocedimentosdiag, NEW.obsexamecomplem, NEW.ordexame, NEW.resultadoexamecomplem); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcexamemedcomplemauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcexamemedcomplemauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCEXAMEMEDCOMPLEMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDCOMPLEMHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, seqexame, datarealizacaoexame, codigoprocedimentosdiag, obsexamecomplem, ordexame, resultadoexamecomplem) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigoexamemed, OLD.dataexame, OLD.seqexame, OLD.datarealizacaoexame, OLD.codigoprocedimentosdiag, OLD.obsexamecomplem, OLD.ordexame, OLD.resultadoexamecomplem); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCEXAMEMEDCOMPLEMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDCOMPLEMHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, seqexame, datarealizacaoexame, codigoprocedimentosdiag, obsexamecomplem, ordexame, resultadoexamecomplem) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.codigoexamemed, NEW.dataexame, NEW.seqexame, NEW.datarealizacaoexame, NEW.codigoprocedimentosdiag, NEW.obsexamecomplem, NEW.ordexame, NEW.resultadoexamecomplem); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcexamemedcomplembdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcexamemedcomplembdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCEXAMEMEDCOMPLEMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCEXAMEMEDCOMPLEMHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, codigoexamemed, dataexame, seqexame, datarealizacaoexame, codigoprocedimentosdiag, obsexamecomplem, ordexame, resultadoexamecomplem) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.codigoexamemed, OLD.dataexame, OLD.seqexame, OLD.datarealizacaoexame, OLD.codigoprocedimentosdiag, OLD.obsexamecomplem, OLD.ordexame, OLD.resultadoexamecomplem); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funclocalaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funclocalaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCLOCALHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCLOCALHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datatransf, codigoestab, classiforgan, livroreg, folhalivroreg, fichareg, datahoracadast, codigomotivo, tipoadmrais, tipoadmcaged, tipoafastsefip, tipoafastrais, tipoafastcaged, tipoadm, tipotransf, indicatadm, tipoalteracaoesocial, numeroprocesso) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datatransf, NEW.codigoestab, NEW.classiforgan, NEW.livroreg, NEW.folhalivroreg, NEW.fichareg, NEW.datahoracadast, NEW.codigomotivo, NEW.tipoadmrais, NEW.tipoadmcaged, NEW.tipoafastsefip, NEW.tipoafastrais, NEW.tipoafastcaged, NEW.tipoadm, NEW.tipotransf, NEW.indicatadm, NEW.tipoalteracaoesocial, NEW.numeroprocesso); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funclocalauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funclocalauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCLOCALHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCLOCALHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datatransf, codigoestab, classiforgan, livroreg, folhalivroreg, fichareg, datahoracadast, codigomotivo, tipoadmrais, tipoadmcaged, tipoafastsefip, tipoafastrais, tipoafastcaged, tipoadm, tipotransf, indicatadm, tipoalteracaoesocial, numeroprocesso) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datatransf, OLD.codigoestab, OLD.classiforgan, OLD.livroreg, OLD.folhalivroreg, OLD.fichareg, OLD.datahoracadast, OLD.codigomotivo, OLD.tipoadmrais, OLD.tipoadmcaged, OLD.tipoafastsefip, OLD.tipoafastrais, OLD.tipoafastcaged, OLD.tipoadm, OLD.tipotransf, OLD.indicatadm, OLD.tipoalteracaoesocial, OLD.numeroprocesso); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCLOCALHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCLOCALHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datatransf, codigoestab, classiforgan, livroreg, folhalivroreg, fichareg, datahoracadast, codigomotivo, tipoadmrais, tipoadmcaged, tipoafastsefip, tipoafastrais, tipoafastcaged, tipoadm, tipotransf, indicatadm, tipoalteracaoesocial, numeroprocesso) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datatransf, NEW.codigoestab, NEW.classiforgan, NEW.livroreg, NEW.folhalivroreg, NEW.fichareg, NEW.datahoracadast, NEW.codigomotivo, NEW.tipoadmrais, NEW.tipoadmcaged, NEW.tipoafastsefip, NEW.tipoafastrais, NEW.tipoafastcaged, NEW.tipoadm, NEW.tipotransf, NEW.indicatadm, NEW.tipoalteracaoesocial, NEW.numeroprocesso); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funclocalbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funclocalbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCLOCALHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCLOCALHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datatransf, codigoestab, classiforgan, livroreg, folhalivroreg, fichareg, datahoracadast, codigomotivo, tipoadmrais, tipoadmcaged, tipoafastsefip, tipoafastrais, tipoafastcaged, tipoadm, tipotransf, indicatadm, tipoalteracaoesocial, numeroprocesso) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datatransf, OLD.codigoestab, OLD.classiforgan, OLD.livroreg, OLD.folhalivroreg, OLD.fichareg, OLD.datahoracadast, OLD.codigomotivo, OLD.tipoadmrais, OLD.tipoadmcaged, OLD.tipoafastsefip, OLD.tipoafastrais, OLD.tipoafastcaged, OLD.tipoadm, OLD.tipotransf, OLD.indicatadm, OLD.tipoalteracaoesocial, OLD.numeroprocesso); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcoutraempaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcoutraempaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCOUTRAEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCOUTRAEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigooutemp, codigomotivo, codigoproftipoaula, codigocentrocusto, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.datafinal, NEW.codigooutemp, NEW.codigomotivo, NEW.codigoproftipoaula, NEW.codigocentrocusto, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcoutraempauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcoutraempauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCOUTRAEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCOUTRAEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigooutemp, codigomotivo, codigoproftipoaula, codigocentrocusto, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.datafinal, OLD.codigooutemp, OLD.codigomotivo, OLD.codigoproftipoaula, OLD.codigocentrocusto, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCOUTRAEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCOUTRAEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigooutemp, codigomotivo, codigoproftipoaula, codigocentrocusto, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.datafinal, NEW.codigooutemp, NEW.codigomotivo, NEW.codigoproftipoaula, NEW.codigocentrocusto, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcoutraempbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcoutraempbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCOUTRAEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCOUTRAEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, datafinal, codigooutemp, codigomotivo, codigoproftipoaula, codigocentrocusto, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.datafinal, OLD.codigooutemp, OLD.codigomotivo, OLD.codigoproftipoaula, OLD.codigocentrocusto, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcpercalculobdf" procedure_source="CREATE OR REPLACE FUNCTION public.funcpercalculobdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010; &#010;BEGIN &#010;    RETURN OLD;&#010;END&#010;$function$&#010;"/>
<ROW pro_key="funcpessoaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcpessoaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCPESSOAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPESSOAHS(SEQHISTORICO, OPERACAO, codigofuncpessoa, nomefunc, nomesocial, apelidofunc, codigotipolograd, enderfunc, complender, numeroender, bairrofunc, siglaestado, codigomunic, codigopostal, cepfunc, dddfone, numerofone, dddcelular, numerocelular, ramalfone, endereletr, datanasc, siglaestadonasc, codigomunicnasc, sexo, racacor, deffisica, defvisual, brpdhppp, defmental, defauditiva, defobs, defcota, defreabilitado, defintelectual, estadocivil, grauinstr, nacionalidade, datachegada, tipovisto, codigoorgaoemissorrne, cartrne, validrne, expedicaorne, datanatural, pisfunc, datacadpis, codigoorgaoemissorrg, cpffunc, numerorg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhfunc, codigoorgaoemissorcnh, categcnh, expedicaocnh, validcnh, cartreserv, categcartreserv, validaderegist, numerocns, codigoconselho, numeroregist, dataregist, paisorigem, certciviltipo, certcivilemissao, certciviltermo, certcivillivro, certcivilfolha, certcivilcartorio, codigoorgaoemissorpasport, certcivilsiglaestado, certcivilmunic, passapnumero, passapsiglaestado, passapemissao, passapvalidade, codigoorgaoemissorric, passappaisemissao, portnatnumero, complrg, portnatdata, ricnumero, ricsiglaestado, ricmunic, ricdataexped, ufcnh, primhabcnh, casadobr, filhosbr, observ, tipoalteracaoesocial, tmpresid) &#013;&#010;  VALUES (GEN, 1, NEW.codigofuncpessoa, NEW.nomefunc, NEW.nomesocial, NEW.apelidofunc, NEW.codigotipolograd, NEW.enderfunc, NEW.complender, NEW.numeroender, NEW.bairrofunc, NEW.siglaestado, NEW.codigomunic, NEW.codigopostal, NEW.cepfunc, NEW.dddfone, NEW.numerofone, NEW.dddcelular, NEW.numerocelular, NEW.ramalfone, NEW.endereletr, NEW.datanasc, NEW.siglaestadonasc, NEW.codigomunicnasc, NEW.sexo, NEW.racacor, NEW.deffisica, NEW.defvisual, NEW.brpdhppp, NEW.defmental, NEW.defauditiva, NEW.defobs, NEW.defcota, NEW.defreabilitado, NEW.defintelectual, NEW.estadocivil, NEW.grauinstr, NEW.nacionalidade, NEW.datachegada, NEW.tipovisto, NEW.codigoorgaoemissorrne, NEW.cartrne, NEW.validrne, NEW.expedicaorne, NEW.datanatural, NEW.pisfunc, NEW.datacadpis, NEW.codigoorgaoemissorrg, NEW.cpffunc, NEW.numerorg, NEW.siglaestadorg, NEW.emissrg, NEW.titeleit, NEW.zonatiteleit, NEW.secaotiteleit, NEW.cnhfunc, NEW.codigoorgaoemissorcnh, NEW.categcnh, NEW.expedicaocnh, NEW.validcnh, NEW.cartreserv, NEW.categcartreserv, NEW.validaderegist, NEW.numerocns, NEW.codigoconselho, NEW.numeroregist, NEW.dataregist, NEW.paisorigem, NEW.certciviltipo, NEW.certcivilemissao, NEW.certciviltermo, NEW.certcivillivro, NEW.certcivilfolha, NEW.certcivilcartorio, NEW.codigoorgaoemissorpasport, NEW.certcivilsiglaestado, NEW.certcivilmunic, NEW.passapnumero, NEW.passapsiglaestado, NEW.passapemissao, NEW.passapvalidade, NEW.codigoorgaoemissorric, NEW.passappaisemissao, NEW.portnatnumero, NEW.complrg, NEW.portnatdata, NEW.ricnumero, NEW.ricsiglaestado, NEW.ricmunic, NEW.ricdataexped, NEW.ufcnh, NEW.primhabcnh, NEW.casadobr, NEW.filhosbr, NEW.observ, NEW.tipoalteracaoesocial, NEW.tmpresid); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcpessoaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcpessoaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCPESSOAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPESSOAHS(SEQHISTORICO, OPERACAO, codigofuncpessoa, nomefunc, nomesocial, apelidofunc, codigotipolograd, enderfunc, complender, numeroender, bairrofunc, siglaestado, codigomunic, codigopostal, cepfunc, dddfone, numerofone, dddcelular, numerocelular, ramalfone, endereletr, datanasc, siglaestadonasc, codigomunicnasc, sexo, racacor, deffisica, defvisual, brpdhppp, defmental, defauditiva, defobs, defcota, defreabilitado, defintelectual, estadocivil, grauinstr, nacionalidade, datachegada, tipovisto, codigoorgaoemissorrne, cartrne, validrne, expedicaorne, datanatural, pisfunc, datacadpis, codigoorgaoemissorrg, cpffunc, numerorg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhfunc, codigoorgaoemissorcnh, categcnh, expedicaocnh, validcnh, cartreserv, categcartreserv, validaderegist, numerocns, codigoconselho, numeroregist, dataregist, paisorigem, certciviltipo, certcivilemissao, certciviltermo, certcivillivro, certcivilfolha, certcivilcartorio, codigoorgaoemissorpasport, certcivilsiglaestado, certcivilmunic, passapnumero, passapsiglaestado, passapemissao, passapvalidade, codigoorgaoemissorric, passappaisemissao, portnatnumero, complrg, portnatdata, ricnumero, ricsiglaestado, ricmunic, ricdataexped, ufcnh, primhabcnh, casadobr, filhosbr, observ, tipoalteracaoesocial, tmpresid) &#013;&#010;  VALUES (GEN, 2, OLD.codigofuncpessoa, OLD.nomefunc, OLD.nomesocial, OLD.apelidofunc, OLD.codigotipolograd, OLD.enderfunc, OLD.complender, OLD.numeroender, OLD.bairrofunc, OLD.siglaestado, OLD.codigomunic, OLD.codigopostal, OLD.cepfunc, OLD.dddfone, OLD.numerofone, OLD.dddcelular, OLD.numerocelular, OLD.ramalfone, OLD.endereletr, OLD.datanasc, OLD.siglaestadonasc, OLD.codigomunicnasc, OLD.sexo, OLD.racacor, OLD.deffisica, OLD.defvisual, OLD.brpdhppp, OLD.defmental, OLD.defauditiva, OLD.defobs, OLD.defcota, OLD.defreabilitado, OLD.defintelectual, OLD.estadocivil, OLD.grauinstr, OLD.nacionalidade, OLD.datachegada, OLD.tipovisto, OLD.codigoorgaoemissorrne, OLD.cartrne, OLD.validrne, OLD.expedicaorne, OLD.datanatural, OLD.pisfunc, OLD.datacadpis, OLD.codigoorgaoemissorrg, OLD.cpffunc, OLD.numerorg, OLD.siglaestadorg, OLD.emissrg, OLD.titeleit, OLD.zonatiteleit, OLD.secaotiteleit, OLD.cnhfunc, OLD.codigoorgaoemissorcnh, OLD.categcnh, OLD.expedicaocnh, OLD.validcnh, OLD.cartreserv, OLD.categcartreserv, OLD.validaderegist, OLD.numerocns, OLD.codigoconselho, OLD.numeroregist, OLD.dataregist, OLD.paisorigem, OLD.certciviltipo, OLD.certcivilemissao, OLD.certciviltermo, OLD.certcivillivro, OLD.certcivilfolha, OLD.certcivilcartorio, OLD.codigoorgaoemissorpasport, OLD.certcivilsiglaestado, OLD.certcivilmunic, OLD.passapnumero, OLD.passapsiglaestado, OLD.passapemissao, OLD.passapvalidade, OLD.codigoorgaoemissorric, OLD.passappaisemissao, OLD.portnatnumero, OLD.complrg, OLD.portnatdata, OLD.ricnumero, OLD.ricsiglaestado, OLD.ricmunic, OLD.ricdataexped, OLD.ufcnh, OLD.primhabcnh, OLD.casadobr, OLD.filhosbr, OLD.observ, OLD.tipoalteracaoesocial, OLD.tmpresid); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCPESSOAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPESSOAHS(SEQHISTORICO, OPERACAO, codigofuncpessoa, nomefunc, nomesocial, apelidofunc, codigotipolograd, enderfunc, complender, numeroender, bairrofunc, siglaestado, codigomunic, codigopostal, cepfunc, dddfone, numerofone, dddcelular, numerocelular, ramalfone, endereletr, datanasc, siglaestadonasc, codigomunicnasc, sexo, racacor, deffisica, defvisual, brpdhppp, defmental, defauditiva, defobs, defcota, defreabilitado, defintelectual, estadocivil, grauinstr, nacionalidade, datachegada, tipovisto, codigoorgaoemissorrne, cartrne, validrne, expedicaorne, datanatural, pisfunc, datacadpis, codigoorgaoemissorrg, cpffunc, numerorg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhfunc, codigoorgaoemissorcnh, categcnh, expedicaocnh, validcnh, cartreserv, categcartreserv, validaderegist, numerocns, codigoconselho, numeroregist, dataregist, paisorigem, certciviltipo, certcivilemissao, certciviltermo, certcivillivro, certcivilfolha, certcivilcartorio, codigoorgaoemissorpasport, certcivilsiglaestado, certcivilmunic, passapnumero, passapsiglaestado, passapemissao, passapvalidade, codigoorgaoemissorric, passappaisemissao, portnatnumero, complrg, portnatdata, ricnumero, ricsiglaestado, ricmunic, ricdataexped, ufcnh, primhabcnh, casadobr, filhosbr, observ, tipoalteracaoesocial, tmpresid) &#013;&#010;  VALUES (GEN, 3, NEW.codigofuncpessoa, NEW.nomefunc, NEW.nomesocial, NEW.apelidofunc, NEW.codigotipolograd, NEW.enderfunc, NEW.complender, NEW.numeroender, NEW.bairrofunc, NEW.siglaestado, NEW.codigomunic, NEW.codigopostal, NEW.cepfunc, NEW.dddfone, NEW.numerofone, NEW.dddcelular, NEW.numerocelular, NEW.ramalfone, NEW.endereletr, NEW.datanasc, NEW.siglaestadonasc, NEW.codigomunicnasc, NEW.sexo, NEW.racacor, NEW.deffisica, NEW.defvisual, NEW.brpdhppp, NEW.defmental, NEW.defauditiva, NEW.defobs, NEW.defcota, NEW.defreabilitado, NEW.defintelectual, NEW.estadocivil, NEW.grauinstr, NEW.nacionalidade, NEW.datachegada, NEW.tipovisto, NEW.codigoorgaoemissorrne, NEW.cartrne, NEW.validrne, NEW.expedicaorne, NEW.datanatural, NEW.pisfunc, NEW.datacadpis, NEW.codigoorgaoemissorrg, NEW.cpffunc, NEW.numerorg, NEW.siglaestadorg, NEW.emissrg, NEW.titeleit, NEW.zonatiteleit, NEW.secaotiteleit, NEW.cnhfunc, NEW.codigoorgaoemissorcnh, NEW.categcnh, NEW.expedicaocnh, NEW.validcnh, NEW.cartreserv, NEW.categcartreserv, NEW.validaderegist, NEW.numerocns, NEW.codigoconselho, NEW.numeroregist, NEW.dataregist, NEW.paisorigem, NEW.certciviltipo, NEW.certcivilemissao, NEW.certciviltermo, NEW.certcivillivro, NEW.certcivilfolha, NEW.certcivilcartorio, NEW.codigoorgaoemissorpasport, NEW.certcivilsiglaestado, NEW.certcivilmunic, NEW.passapnumero, NEW.passapsiglaestado, NEW.passapemissao, NEW.passapvalidade, NEW.codigoorgaoemissorric, NEW.passappaisemissao, NEW.portnatnumero, NEW.complrg, NEW.portnatdata, NEW.ricnumero, NEW.ricsiglaestado, NEW.ricmunic, NEW.ricdataexped, NEW.ufcnh, NEW.primhabcnh, NEW.casadobr, NEW.filhosbr, NEW.observ, NEW.tipoalteracaoesocial, NEW.tmpresid); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcpessoabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcpessoabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;FUNCPESSOAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPESSOAHS(SEQHISTORICO, OPERACAO, codigofuncpessoa, nomefunc, nomesocial, apelidofunc, codigotipolograd, enderfunc, complender, numeroender, bairrofunc, siglaestado, codigomunic, codigopostal, cepfunc, dddfone, numerofone, dddcelular, numerocelular, ramalfone, endereletr, datanasc, siglaestadonasc, codigomunicnasc, sexo, racacor, deffisica, defvisual, brpdhppp, defmental, defauditiva, defobs, defcota, defreabilitado, defintelectual, estadocivil, grauinstr, nacionalidade, datachegada, tipovisto, codigoorgaoemissorrne, cartrne, validrne, expedicaorne, datanatural, pisfunc, datacadpis, codigoorgaoemissorrg, cpffunc, numerorg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhfunc, codigoorgaoemissorcnh, categcnh, expedicaocnh, validcnh, cartreserv, categcartreserv, validaderegist, numerocns, codigoconselho, numeroregist, dataregist, paisorigem, certciviltipo, certcivilemissao, certciviltermo, certcivillivro, certcivilfolha, certcivilcartorio, codigoorgaoemissorpasport, certcivilsiglaestado, certcivilmunic, passapnumero, passapsiglaestado, passapemissao, passapvalidade, codigoorgaoemissorric, passappaisemissao, portnatnumero, complrg, portnatdata, ricnumero, ricsiglaestado, ricmunic, ricdataexped, ufcnh, primhabcnh, casadobr, filhosbr, observ, tipoalteracaoesocial, tmpresid) &#013;&#010;  VALUES (GEN, 4, OLD.codigofuncpessoa, OLD.nomefunc, OLD.nomesocial, OLD.apelidofunc, OLD.codigotipolograd, OLD.enderfunc, OLD.complender, OLD.numeroender, OLD.bairrofunc, OLD.siglaestado, OLD.codigomunic, OLD.codigopostal, OLD.cepfunc, OLD.dddfone, OLD.numerofone, OLD.dddcelular, OLD.numerocelular, OLD.ramalfone, OLD.endereletr, OLD.datanasc, OLD.siglaestadonasc, OLD.codigomunicnasc, OLD.sexo, OLD.racacor, OLD.deffisica, OLD.defvisual, OLD.brpdhppp, OLD.defmental, OLD.defauditiva, OLD.defobs, OLD.defcota, OLD.defreabilitado, OLD.defintelectual, OLD.estadocivil, OLD.grauinstr, OLD.nacionalidade, OLD.datachegada, OLD.tipovisto, OLD.codigoorgaoemissorrne, OLD.cartrne, OLD.validrne, OLD.expedicaorne, OLD.datanatural, OLD.pisfunc, OLD.datacadpis, OLD.codigoorgaoemissorrg, OLD.cpffunc, OLD.numerorg, OLD.siglaestadorg, OLD.emissrg, OLD.titeleit, OLD.zonatiteleit, OLD.secaotiteleit, OLD.cnhfunc, OLD.codigoorgaoemissorcnh, OLD.categcnh, OLD.expedicaocnh, OLD.validcnh, OLD.cartreserv, OLD.categcartreserv, OLD.validaderegist, OLD.numerocns, OLD.codigoconselho, OLD.numeroregist, OLD.dataregist, OLD.paisorigem, OLD.certciviltipo, OLD.certcivilemissao, OLD.certciviltermo, OLD.certcivillivro, OLD.certcivilfolha, OLD.certcivilcartorio, OLD.codigoorgaoemissorpasport, OLD.certcivilsiglaestado, OLD.certcivilmunic, OLD.passapnumero, OLD.passapsiglaestado, OLD.passapemissao, OLD.passapvalidade, OLD.codigoorgaoemissorric, OLD.passappaisemissao, OLD.portnatnumero, OLD.complrg, OLD.portnatdata, OLD.ricnumero, OLD.ricsiglaestado, OLD.ricmunic, OLD.ricdataexped, OLD.ufcnh, OLD.primhabcnh, OLD.casadobr, OLD.filhosbr, OLD.observ, OLD.tipoalteracaoesocial, OLD.tmpresid); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcprocessotrabtribaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcprocessotrabtribaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCPROCESSOTRABTRIBHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPROCESSOTRABTRIBHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, datapgto, obs) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.nrproctrab, NEW.datapgto, NEW.obs); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcprocessotrabtribauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcprocessotrabtribauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCPROCESSOTRABTRIBHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPROCESSOTRABTRIBHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, datapgto, obs) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.nrproctrab, OLD.datapgto, OLD.obs); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCPROCESSOTRABTRIBHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPROCESSOTRABTRIBHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, datapgto, obs) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.nrproctrab, NEW.datapgto, NEW.obs); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcprocessotrabtribbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcprocessotrabtribbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCPROCESSOTRABTRIBHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCPROCESSOTRABTRIBHS(SEQHISTORICO, OPERACAO, codigoempresa, nrproctrab, datapgto, obs) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.nrproctrab, OLD.datapgto, OLD.obs); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcsalarioaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcsalarioaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCSALARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSALARIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoestrutsal, codigotabsal, codigomotivo, tiposalario, valorsal, complsal, antecsal, percaumento, salcarne, descrsal, tipoalteracaoesocial, seq, dataefeito, codigosinddissidioemp) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigoestrutsal, NEW.codigotabsal, NEW.codigomotivo, NEW.tiposalario, NEW.valorsal, NEW.complsal, NEW.antecsal, NEW.percaumento, NEW.salcarne, NEW.descrsal, NEW.tipoalteracaoesocial, NEW.seq, NEW.dataefeito, NEW.codigosinddissidioemp); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcsalarioauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcsalarioauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCSALARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSALARIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoestrutsal, codigotabsal, codigomotivo, tiposalario, valorsal, complsal, antecsal, percaumento, salcarne, descrsal, tipoalteracaoesocial, seq, dataefeito, codigosinddissidioemp) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigoestrutsal, OLD.codigotabsal, OLD.codigomotivo, OLD.tiposalario, OLD.valorsal, OLD.complsal, OLD.antecsal, OLD.percaumento, OLD.salcarne, OLD.descrsal, OLD.tipoalteracaoesocial, OLD.seq, OLD.dataefeito, OLD.codigosinddissidioemp); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCSALARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSALARIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoestrutsal, codigotabsal, codigomotivo, tiposalario, valorsal, complsal, antecsal, percaumento, salcarne, descrsal, tipoalteracaoesocial, seq, dataefeito, codigosinddissidioemp) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigoestrutsal, NEW.codigotabsal, NEW.codigomotivo, NEW.tiposalario, NEW.valorsal, NEW.complsal, NEW.antecsal, NEW.percaumento, NEW.salcarne, NEW.descrsal, NEW.tipoalteracaoesocial, NEW.seq, NEW.dataefeito, NEW.codigosinddissidioemp); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcsalariobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcsalariobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCSALARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSALARIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigoestrutsal, codigotabsal, codigomotivo, tiposalario, valorsal, complsal, antecsal, percaumento, salcarne, descrsal, tipoalteracaoesocial, seq, dataefeito, codigosinddissidioemp) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigoestrutsal, OLD.codigotabsal, OLD.codigomotivo, OLD.tiposalario, OLD.valorsal, OLD.complsal, OLD.antecsal, OLD.percaumento, OLD.salcarne, OLD.descrsal, OLD.tipoalteracaoesocial, OLD.seq, OLD.dataefeito, OLD.codigosinddissidioemp); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcsindicatoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcsindicatoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCSINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSINDICATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, sindicalizado, mestaxaassistencial, codigosind, descmenssind, desccustconfed, desctaxaassist, descontarevsal, desccontribsind, descanoadmissao, mescontribsind, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.sindicalizado, NEW.mestaxaassistencial, NEW.codigosind, NEW.descmenssind, NEW.desccustconfed, NEW.desctaxaassist, NEW.descontarevsal, NEW.desccontribsind, NEW.descanoadmissao, NEW.mescontribsind, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcsindicatoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcsindicatoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCSINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSINDICATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, sindicalizado, mestaxaassistencial, codigosind, descmenssind, desccustconfed, desctaxaassist, descontarevsal, desccontribsind, descanoadmissao, mescontribsind, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.sindicalizado, OLD.mestaxaassistencial, OLD.codigosind, OLD.descmenssind, OLD.desccustconfed, OLD.desctaxaassist, OLD.descontarevsal, OLD.desccontribsind, OLD.descanoadmissao, OLD.mescontribsind, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCSINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSINDICATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, sindicalizado, mestaxaassistencial, codigosind, descmenssind, desccustconfed, desctaxaassist, descontarevsal, desccontribsind, descanoadmissao, mescontribsind, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.sindicalizado, NEW.mestaxaassistencial, NEW.codigosind, NEW.descmenssind, NEW.desccustconfed, NEW.desctaxaassist, NEW.descontarevsal, NEW.desccontribsind, NEW.descanoadmissao, NEW.mescontribsind, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="funcsindicatobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.funcsindicatobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCSINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCSINDICATOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, sindicalizado, mestaxaassistencial, codigosind, descmenssind, desccustconfed, desctaxaassist, descontarevsal, desccontribsind, descanoadmissao, mescontribsind, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.sindicalizado, OLD.mestaxaassistencial, OLD.codigosind, OLD.descmenssind, OLD.desccustconfed, OLD.desctaxaassist, OLD.descontarevsal, OLD.desccontribsind, OLD.descanoadmissao, OLD.mescontribsind, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="functreinamentocapacitacaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.functreinamentocapacitacaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCTREINAMENTOCAPACITACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCTREINAMENTOCAPACITACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigotreinamento, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigotreinamento, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="functreinamentocapacitacaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.functreinamentocapacitacaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCTREINAMENTOCAPACITACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCTREINAMENTOCAPACITACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigotreinamento, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigotreinamento, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;FUNCTREINAMENTOCAPACITACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCTREINAMENTOCAPACITACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigotreinamento, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigofunccontr, NEW.datainicial, NEW.codigotreinamento, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="functreinamentocapacitacaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.functreinamentocapacitacaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;FUNCTREINAMENTOCAPACITACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO FUNCTREINAMENTOCAPACITACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigofunccontr, datainicial, codigotreinamento, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigofunccontr, OLD.datainicial, OLD.codigotreinamento, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="gpsaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.gpsaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;GPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO GPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigotabgps, datainicial, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigoimpostoterc, variacaoimpostoterc, codigoimpostoterc13, variacaoimpostoterc13, codigofpas, codigoacidtrab, terceiros, percparteemp, percentfinanc, percprodrurais, percpartesat, percparteterc, percdirauton, percisencaofilant, percacrescfap, codigoprocessojudadmrat, perccooptrab, codigoprocessojudadmter, codigoprocessojudadmfap, percratcomproc, terceiroscomproc, perctercomproc, percfapcomproc, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigotabgps, NEW.datainicial, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigoimposto13, NEW.variacaoimposto13, NEW.codigoimpostoterc, NEW.variacaoimpostoterc, NEW.codigoimpostoterc13, NEW.variacaoimpostoterc13, NEW.codigofpas, NEW.codigoacidtrab, NEW.terceiros, NEW.percparteemp, NEW.percentfinanc, NEW.percprodrurais, NEW.percpartesat, NEW.percparteterc, NEW.percdirauton, NEW.percisencaofilant, NEW.percacrescfap, NEW.codigoprocessojudadmrat, NEW.perccooptrab, NEW.codigoprocessojudadmter, NEW.codigoprocessojudadmfap, NEW.percratcomproc, NEW.terceiroscomproc, NEW.perctercomproc, NEW.percfapcomproc, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="gpsauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.gpsauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;GPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO GPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigotabgps, datainicial, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigoimpostoterc, variacaoimpostoterc, codigoimpostoterc13, variacaoimpostoterc13, codigofpas, codigoacidtrab, terceiros, percparteemp, percentfinanc, percprodrurais, percpartesat, percparteterc, percdirauton, percisencaofilant, percacrescfap, codigoprocessojudadmrat, perccooptrab, codigoprocessojudadmter, codigoprocessojudadmfap, percratcomproc, terceiroscomproc, perctercomproc, percfapcomproc, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigotabgps, OLD.datainicial, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigoimposto13, OLD.variacaoimposto13, OLD.codigoimpostoterc, OLD.variacaoimpostoterc, OLD.codigoimpostoterc13, OLD.variacaoimpostoterc13, OLD.codigofpas, OLD.codigoacidtrab, OLD.terceiros, OLD.percparteemp, OLD.percentfinanc, OLD.percprodrurais, OLD.percpartesat, OLD.percparteterc, OLD.percdirauton, OLD.percisencaofilant, OLD.percacrescfap, OLD.codigoprocessojudadmrat, OLD.perccooptrab, OLD.codigoprocessojudadmter, OLD.codigoprocessojudadmfap, OLD.percratcomproc, OLD.terceiroscomproc, OLD.perctercomproc, OLD.percfapcomproc, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;GPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO GPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigotabgps, datainicial, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigoimpostoterc, variacaoimpostoterc, codigoimpostoterc13, variacaoimpostoterc13, codigofpas, codigoacidtrab, terceiros, percparteemp, percentfinanc, percprodrurais, percpartesat, percparteterc, percdirauton, percisencaofilant, percacrescfap, codigoprocessojudadmrat, perccooptrab, codigoprocessojudadmter, codigoprocessojudadmfap, percratcomproc, terceiroscomproc, perctercomproc, percfapcomproc, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigotabgps, NEW.datainicial, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigoimposto13, NEW.variacaoimposto13, NEW.codigoimpostoterc, NEW.variacaoimpostoterc, NEW.codigoimpostoterc13, NEW.variacaoimpostoterc13, NEW.codigofpas, NEW.codigoacidtrab, NEW.terceiros, NEW.percparteemp, NEW.percentfinanc, NEW.percprodrurais, NEW.percpartesat, NEW.percparteterc, NEW.percdirauton, NEW.percisencaofilant, NEW.percacrescfap, NEW.codigoprocessojudadmrat, NEW.perccooptrab, NEW.codigoprocessojudadmter, NEW.codigoprocessojudadmfap, NEW.percratcomproc, NEW.terceiroscomproc, NEW.perctercomproc, NEW.percfapcomproc, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="gpsbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.gpsbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;GPSHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO GPSHS(SEQHISTORICO, OPERACAO, codigoempresa, codigotabgps, datainicial, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigoimpostoterc, variacaoimpostoterc, codigoimpostoterc13, variacaoimpostoterc13, codigofpas, codigoacidtrab, terceiros, percparteemp, percentfinanc, percprodrurais, percpartesat, percparteterc, percdirauton, percisencaofilant, percacrescfap, codigoprocessojudadmrat, perccooptrab, codigoprocessojudadmter, codigoprocessojudadmfap, percratcomproc, terceiroscomproc, perctercomproc, percfapcomproc, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigotabgps, OLD.datainicial, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigoimposto13, OLD.variacaoimposto13, OLD.codigoimpostoterc, OLD.variacaoimpostoterc, OLD.codigoimpostoterc13, OLD.variacaoimpostoterc13, OLD.codigofpas, OLD.codigoacidtrab, OLD.terceiros, OLD.percparteemp, OLD.percentfinanc, OLD.percprodrurais, OLD.percpartesat, OLD.percparteterc, OLD.percdirauton, OLD.percisencaofilant, OLD.percacrescfap, OLD.codigoprocessojudadmrat, OLD.perccooptrab, OLD.codigoprocessojudadmter, OLD.codigoprocessojudadmfap, OLD.percratcomproc, OLD.terceiroscomproc, OLD.perctercomproc, OLD.percfapcomproc, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="historicoalteracaoesocialbif" procedure_source="CREATE OR REPLACE FUNCTION public.historicoalteracaoesocialbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.SEQ is null) THEN&#013;&#010;    new.SEQ = NEXTVAL(&apos;gen_historicoalteracaoesocial&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_historicoalteracaoesocial&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_historicoalteracaoesocial;&#013;&#010;END;&#013;&#010;WHILE (NEW.SEQ &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_historicoalteracaoesocial&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="historicoempresaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.historicoempresaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;HISTORICOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HISTORICOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, seq, dataevento, tipoevento, motivo, anotacoes, codigousuario, datahoralcto) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.seq, NEW.dataevento, NEW.tipoevento, NEW.motivo, NEW.anotacoes, NEW.codigousuario, NEW.datahoralcto); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="historicoempresaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.historicoempresaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;HISTORICOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HISTORICOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, seq, dataevento, tipoevento, motivo, anotacoes, codigousuario, datahoralcto) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.seq, OLD.dataevento, OLD.tipoevento, OLD.motivo, OLD.anotacoes, OLD.codigousuario, OLD.datahoralcto); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;HISTORICOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HISTORICOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, seq, dataevento, tipoevento, motivo, anotacoes, codigousuario, datahoralcto) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.seq, NEW.dataevento, NEW.tipoevento, NEW.motivo, NEW.anotacoes, NEW.codigousuario, NEW.datahoralcto); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="historicoempresabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.historicoempresabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;HISTORICOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HISTORICOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, seq, dataevento, tipoevento, motivo, anotacoes, codigousuario, datahoralcto) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.seq, OLD.dataevento, OLD.tipoevento, OLD.motivo, OLD.anotacoes, OLD.codigousuario, OLD.datahoralcto); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horarioaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.horarioaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOHS(SEQHISTORICO, OPERACAO, codigohorario, datainicial, descrhorario, intrajornada, tipohorario, horasintrajordiurna, permiteflex, tipointerval, horasintrajornoturna, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigohorario, NEW.datainicial, NEW.descrhorario, NEW.intrajornada, NEW.tipohorario, NEW.horasintrajordiurna, NEW.permiteflex, NEW.tipointerval, NEW.horasintrajornoturna, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horarioauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.horarioauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOHS(SEQHISTORICO, OPERACAO, codigohorario, datainicial, descrhorario, intrajornada, tipohorario, horasintrajordiurna, permiteflex, tipointerval, horasintrajornoturna, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigohorario, OLD.datainicial, OLD.descrhorario, OLD.intrajornada, OLD.tipohorario, OLD.horasintrajordiurna, OLD.permiteflex, OLD.tipointerval, OLD.horasintrajornoturna, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOHS(SEQHISTORICO, OPERACAO, codigohorario, datainicial, descrhorario, intrajornada, tipohorario, horasintrajordiurna, permiteflex, tipointerval, horasintrajornoturna, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigohorario, NEW.datainicial, NEW.descrhorario, NEW.intrajornada, NEW.tipohorario, NEW.horasintrajordiurna, NEW.permiteflex, NEW.tipointerval, NEW.horasintrajornoturna, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horariobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.horariobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOHS(SEQHISTORICO, OPERACAO, codigohorario, datainicial, descrhorario, intrajornada, tipohorario, horasintrajordiurna, permiteflex, tipointerval, horasintrajornoturna, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigohorario, OLD.datainicial, OLD.descrhorario, OLD.intrajornada, OLD.tipohorario, OLD.horasintrajordiurna, OLD.permiteflex, OLD.tipointerval, OLD.horasintrajornoturna, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horariodetalheaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.horariodetalheaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIODETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIODETALHEHS(SEQHISTORICO, OPERACAO, codigohorario, seq, datainicial, horaentrada, horasaida, numerohoras, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigohorario, NEW.seq, NEW.datainicial, NEW.horaentrada, NEW.horasaida, NEW.numerohoras, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horariodetalheauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.horariodetalheauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIODETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIODETALHEHS(SEQHISTORICO, OPERACAO, codigohorario, seq, datainicial, horaentrada, horasaida, numerohoras, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigohorario, OLD.seq, OLD.datainicial, OLD.horaentrada, OLD.horasaida, OLD.numerohoras, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIODETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIODETALHEHS(SEQHISTORICO, OPERACAO, codigohorario, seq, datainicial, horaentrada, horasaida, numerohoras, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigohorario, NEW.seq, NEW.datainicial, NEW.horaentrada, NEW.horasaida, NEW.numerohoras, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horariodetalhebdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.horariodetalhebdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;HORARIODETALHEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIODETALHEHS(SEQHISTORICO, OPERACAO, codigohorario, seq, datainicial, horaentrada, horasaida, numerohoras, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigohorario, OLD.seq, OLD.datainicial, OLD.horaentrada, OLD.horasaida, OLD.numerohoras, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horarioempresaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.horarioempresaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;HORARIOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigohorariorelat, codigohorario, datainicial, status) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigohorariorelat, NEW.codigohorario, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horarioempresaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.horarioempresaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;HORARIOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigohorariorelat, codigohorario, datainicial, status) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigohorariorelat, OLD.codigohorario, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;HORARIOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigohorariorelat, codigohorario, datainicial, status) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigohorariorelat, NEW.codigohorario, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="horarioempresabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.horarioempresabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;HORARIOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO HORARIOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigohorariorelat, codigohorario, datainicial, status) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigohorariorelat, OLD.codigohorario, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="icmsesestoqcombustbif" procedure_source="CREATE OR REPLACE FUNCTION public.icmsesestoqcombustbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE&#013;&#010;i integer;&#013;&#010;BEGIN&#013;&#010;  IF (new.IDESTOQCOMBUST is null) THEN&#013;&#010;    new.IDESTOQCOMBUST = NEXTVAL(&apos;gen_idestoqcombust&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_idestoqcombust&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_idestoqcombust;&#013;&#010;END;&#013;&#010;WHILE (NEW.IDESTOQCOMBUST &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_idestoqcombust&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="icmsestotalcombustbif" procedure_source="CREATE OR REPLACE FUNCTION public.icmsestotalcombustbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.IDTOTALCOMBUST is null) THEN&#013;&#010;    new.IDTOTALCOMBUST = NEXTVAL(&apos;gen_idtotalcombust&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_idtotalcombust&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_idtotalcombust;&#013;&#010;END;&#013;&#010;WHILE (NEW.IDTOTALCOMBUST &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_idtotalcombust&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;end;&#013;&#010;$function$&#010;"/>
<ROW pro_key="implsaldoctbaiauf" procedure_source="CREATE OR REPLACE FUNCTION public.implsaldoctbaiauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;aContaCtbDeb numeric(10,0);&#013;&#010;aContaCtbCred numeric(10,0);&#013;&#010;BEGIN&#013;&#010;IF (new.NaturezaSaldo in (1, -1)) THEN&#013;&#010;aContaCtbDeb := null;&#013;&#010;aContaCtbCred := null;&#013;&#010;IF (new.NaturezaSaldo = 1) THEN&#013;&#010;aContaCtbDeb := new.ContaCtb;&#013;&#010;ELSE&#013;&#010;aContaCtbCred := new.ContaCtb;&#013;&#010;END IF;&#013;&#010;IF (new.CodigoMoeda = 0/*Real*/) THEN&#013;&#010;CALL TOTALIZARSALDOCTB(new.CodigoEmpresa, new.CodigoEstab, aContaCtbDeb, aContaCtbCred, new.DataSaldo, new.TipoLancamento, new.ValorSaldo);&#013;&#010;ELSE&#013;&#010;CALL TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa, new.CodigoEstab, aContaCtbDeb, aContaCtbCred, new.DataSaldo, new.TipoLancamento, new.ValorSaldo, new.CodigoMoeda);&#013;&#010;END IF;&#013;&#010;END IF;&#013;&#010;RETURN new; &#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="implsaldoctbbdf" procedure_source="CREATE OR REPLACE FUNCTION public.implsaldoctbbdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE &#013;&#010;aContaCtbDeb numeric(10,0); &#013;&#010;aContaCtbCred numeric(10,0); &#013;&#010;BEGIN &#013;&#010;IF (old.NaturezaSaldo in (1, -1)) THEN &#013;&#010;aContaCtbDeb  = null; &#013;&#010;aContaCtbCred = null; &#013;&#010;IF (old.NaturezaSaldo = 1) THEN &#013;&#010;aContaCtbDeb  = old.ContaCtb; &#013;&#010;ELSE &#013;&#010;aContaCtbCred = old.ContaCtb; &#013;&#010;END IF; &#013;&#010;IF (old.CodigoMoeda = 0/*Real*/) THEN &#013;&#010;CALL SUBTRAIRSALDOCTB(old.CodigoEmpresa, old.CodigoEstab, &#013;&#010;aContaCtbDeb, aContaCtbCred, old.DataSaldo, old.TipoLancamento, old.ValorSaldo); &#013;&#010;ELSE &#013;&#010;CALL SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa, old.CodigoEstab, aContaCtbDeb, &#013;&#010;aContaCtbCred, old.DataSaldo, old.TipoLancamento, old.ValorSaldo, old.CodigoMoeda); &#013;&#010;END IF; &#013;&#010;END IF; &#013;&#010;RETURN OLD; &#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="implsaldoctbbif" procedure_source="CREATE OR REPLACE FUNCTION public.implsaldoctbbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;BEGIN&#013;&#010;  IF (new.TipoLancamento is null) THEN&#013;&#010;    new.TipoLancamento = &apos;LN&apos;;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="implsaldoctbbubdf" procedure_source="CREATE OR REPLACE FUNCTION public.implsaldoctbbubdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE &#013;&#010;aContaCtbDeb numeric(10,0); &#013;&#010;aContaCtbCred numeric(10,0); &#013;&#010;BEGIN &#013;&#010;IF (old.NaturezaSaldo in (1, -1)) THEN &#013;&#010;aContaCtbDeb  = null; &#013;&#010;aContaCtbCred = null; &#013;&#010;IF (old.NaturezaSaldo = 1) THEN &#013;&#010;aContaCtbDeb  = old.ContaCtb; &#013;&#010;ELSE &#013;&#010;aContaCtbCred = old.ContaCtb; &#013;&#010;END IF; &#013;&#010;IF (old.CodigoMoeda = 0/*Real*/) THEN &#013;&#010;CALL SUBTRAIRSALDOCTB(old.CodigoEmpresa, old.CodigoEstab, &#013;&#010;aContaCtbDeb, aContaCtbCred, old.DataSaldo, old.TipoLancamento, old.ValorSaldo); &#013;&#010;ELSE &#013;&#010;CALL SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa, old.CodigoEstab, aContaCtbDeb, &#013;&#010;aContaCtbCred, old.DataSaldo, old.TipoLancamento, old.ValorSaldo, old.CodigoMoeda); &#013;&#010;END IF; &#013;&#010;END IF; &#013;&#010;RETURN NEW; &#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="implsaldoctbbuf" procedure_source="CREATE OR REPLACE FUNCTION public.implsaldoctbbuf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE &#013;&#010;aContaCtbDeb numeric(10,0); &#013;&#010;aContaCtbCred numeric(10,0); &#013;&#010;BEGIN &#013;&#010;IF (old.NaturezaSaldo in (1, -1)) THEN &#013;&#010;aContaCtbDeb  = null; &#013;&#010;aContaCtbCred = null; &#013;&#010;IF (old.NaturezaSaldo = 1) THEN &#013;&#010;aContaCtbDeb  = old.ContaCtb; &#013;&#010;ELSE &#013;&#010;aContaCtbCred = old.ContaCtb; &#013;&#010;END IF; &#013;&#010;IF (old.CodigoMoeda = 0/*Real*/) THEN &#013;&#010;CALL SUBTRAIRSALDOCTB(old.CodigoEmpresa, old.CodigoEstab, &#013;&#010;aContaCtbDeb, aContaCtbCred, old.DataSaldo, old.TipoLancamento, old.ValorSaldo); &#013;&#010;ELSE &#013;&#010;CALL SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa, old.CodigoEstab, aContaCtbDeb, &#013;&#010;aContaCtbCred, old.DataSaldo, old.TipoLancamento, old.ValorSaldo, old.CodigoMoeda); &#013;&#010;END IF; &#013;&#010;END IF; &#013;&#010;RETURN NEW; &#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="jobagendabif" procedure_source="CREATE OR REPLACE FUNCTION public.jobagendabif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;  TMP NUMERIC(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOJOBAGENDA IS NULL) THEN&#013;&#010;    NEW.CODIGOJOBAGENDA = NEXTVAL(&apos;GENJOBAGENDA&apos;);&#013;&#010;  ELSE&#013;&#010;    BEGIN&#013;&#010;      SELECT CURRVAL(&apos;GENJOBAGENDA&apos;) INTO TMP;&#013;&#010;    EXCEPTION WHEN OTHERS THEN&#013;&#010;      SELECT LAST_VALUE INTO TMP FROM GENJOBAGENDA;&#013;&#010;    END;&#013;&#010;    WHILE (NEW.CODIGOJOBAGENDA &gt; TMP) LOOP&#013;&#010;      SELECT NEXTVAL(&apos;GENJOBAGENDA&apos;) INTO TMP;&#013;&#010;    END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="jobbuildbif" procedure_source="CREATE OR REPLACE FUNCTION public.jobbuildbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;  i Numeric(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.CODIGOBUILD is null) THEN&#013;&#010;    new.CODIGOBUILD = NEXTVAL(&apos;GEN_JOBBUILD&apos;);&#013;&#010;  ELSE&#013;&#010;    BEGIN&#013;&#010;      SELECT CURRVAL(&apos;GEN_JOBBUILD&apos;) INTO i;&#013;&#010;    EXCEPTION WHEN OTHERS THEN&#013;&#010;      SELECT last_value INTO i FROM GEN_JOBBUILD;&#013;&#010;    END;&#013;&#010;    WHILE (NEW.CODIGOBUILD &gt; i) LOOP&#013;&#010;      SELECT nextval(&apos;GEN_JOBBUILD&apos;) INTO i;&#013;&#010;    END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="jobconfiguracaobif" procedure_source="CREATE OR REPLACE FUNCTION public.jobconfiguracaobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;  TMP NUMERIC(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOJOBCFG IS NULL) THEN&#013;&#010;    NEW.CODIGOJOBCFG = NEXTVAL(&apos;GENJOBCONFIGURACAO&apos;);&#013;&#010;  ELSE&#013;&#010;    BEGIN&#013;&#010;      SELECT CURRVAL(&apos;GENJOBCONFIGURACAO&apos;) INTO TMP;&#013;&#010;    EXCEPTION WHEN OTHERS THEN&#013;&#010;      SELECT LAST_VALUE INTO TMP FROM GENJOBCONFIGURACAO;&#013;&#010;    END;&#013;&#010;    WHILE (NEW.CODIGOJOBCFG &gt; TMP) LOOP&#013;&#010;      SELECT NEXTVAL(&apos;GENJOBCONFIGURACAO&apos;) INTO TMP;&#013;&#010;    END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="jobparametrobif" procedure_source="CREATE OR REPLACE FUNCTION public.jobparametrobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;  TMP NUMERIC(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOJOBPARAMETRO IS NULL) THEN&#013;&#010;    NEW.CODIGOJOBPARAMETRO = NEXTVAL(&apos;GENJOBPARAMETRO&apos;);&#013;&#010;  ELSE&#013;&#010;    BEGIN&#013;&#010;      SELECT CURRVAL(&apos;GENJOBPARAMETRO&apos;) INTO TMP;&#013;&#010;    EXCEPTION WHEN OTHERS THEN&#013;&#010;      SELECT LAST_VALUE INTO TMP FROM GENJOBPARAMETRO;&#013;&#010;    END;&#013;&#010;    WHILE (NEW.CODIGOJOBPARAMETRO &gt; TMP) LOOP&#013;&#010;      SELECT NEXTVAL(&apos;GENJOBPARAMETRO&apos;) INTO TMP;&#013;&#010;    END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, descricaofatorrisco, obsregamb, tipoavaliacao, intensconcent, limitetolerancia, codigodoseunidade, tecnicautil, utilizaepi, medidaprotecaoepc, epceficaz, epieficaz, nrprocjud) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.descricaofatorrisco, NEW.obsregamb, NEW.tipoavaliacao, NEW.intensconcent, NEW.limitetolerancia, NEW.codigodoseunidade, NEW.tecnicautil, NEW.utilizaepi, NEW.medidaprotecaoepc, NEW.epceficaz, NEW.epieficaz, NEW.nrprocjud); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambcargoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambcargoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigocargo) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo, NEW.codigocargo); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambcargoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambcargoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigocargo) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo, OLD.codigocargo); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigocargo) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo, NEW.codigocargo); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambcargobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambcargobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBCARGOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBCARGOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigocargo) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo, OLD.codigocargo); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambfatriscoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambfatriscoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBFATRISCOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBFATRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigofatorrisco, seq) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo, NEW.codigofatorrisco, NEW.seq); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambfatriscoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambfatriscoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBFATRISCOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBFATRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigofatorrisco, seq) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo, OLD.codigofatorrisco, OLD.seq); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBFATRISCOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBFATRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigofatorrisco, seq) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo, NEW.codigofatorrisco, NEW.seq); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambfatriscobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambfatriscobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBFATRISCOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBFATRISCOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, codigofatorrisco, seq) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo, OLD.codigofatorrisco, OLD.seq); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambienteaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambienteaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBIENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBIENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambienteauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambienteauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBIENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBIENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBIENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBIENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstambientebdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstambientebdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBIENTEHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBIENTEHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstamborganoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstamborganoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBORGANOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBORGANOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, classiforgan) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo, NEW.classiforgan); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstamborganoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstamborganoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBORGANOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBORGANOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, classiforgan) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo, OLD.classiforgan); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBORGANOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBORGANOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, classiforgan) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.datalaudo, NEW.classiforgan); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstamborganobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstamborganobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTAMBORGANOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTAMBORGANOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, datalaudo, classiforgan) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.datalaudo, OLD.classiforgan); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstativaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstativaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTATIVHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTATIVHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigoambientetrab, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigoambientetrab, NEW.codigocargo, NEW.codigoativtrab); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstativauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstativauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTATIVHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTATIVHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigoambientetrab, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigoambientetrab, OLD.codigocargo, OLD.codigoativtrab); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTATIVHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTATIVHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigoambientetrab, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigoambientetrab, NEW.codigocargo, NEW.codigoativtrab); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstativbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstativbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTATIVHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTATIVHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigoambientetrab, codigocargo, codigoativtrab) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigoambientetrab, OLD.codigocargo, OLD.codigoativtrab); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, descricaofatorrisco, obsregamb, tipoavaliacao, intensconcent, limitetolerancia, codigodoseunidade, tecnicautil, utilizaepi, medidaprotecaoepc, epceficaz, epieficaz, nrprocjud) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.descricaofatorrisco, OLD.obsregamb, OLD.tipoavaliacao, OLD.intensconcent, OLD.limitetolerancia, OLD.codigodoseunidade, OLD.tecnicautil, OLD.utilizaepi, OLD.medidaprotecaoepc, OLD.epceficaz, OLD.epieficaz, OLD.nrprocjud); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, descricaofatorrisco, obsregamb, tipoavaliacao, intensconcent, limitetolerancia, codigodoseunidade, tecnicautil, utilizaepi, medidaprotecaoepc, epceficaz, epieficaz, nrprocjud) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.descricaofatorrisco, NEW.obsregamb, NEW.tipoavaliacao, NEW.intensconcent, NEW.limitetolerancia, NEW.codigodoseunidade, NEW.tecnicautil, NEW.utilizaepi, NEW.medidaprotecaoepc, NEW.epceficaz, NEW.epieficaz, NEW.nrprocjud); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, descricaofatorrisco, obsregamb, tipoavaliacao, intensconcent, limitetolerancia, codigodoseunidade, tecnicautil, utilizaepi, medidaprotecaoepc, epceficaz, epieficaz, nrprocjud) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.descricaofatorrisco, OLD.obsregamb, OLD.tipoavaliacao, OLD.intensconcent, OLD.limitetolerancia, OLD.codigodoseunidade, OLD.tecnicautil, OLD.utilizaepi, OLD.medidaprotecaoepc, OLD.epceficaz, OLD.epieficaz, OLD.nrprocjud); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstepiaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstepiaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPIHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqepi, codigoepi) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.seqepi, NEW.codigoepi); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstepiauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstepiauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPIHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqepi, codigoepi) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.seqepi, OLD.codigoepi); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPIHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqepi, codigoepi) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.seqepi, NEW.codigoepi); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstepibdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstepibdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPIHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPIHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqepi, codigoepi) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.seqepi, OLD.codigoepi); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstepicomplaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstepicomplaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPICOMPLHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPICOMPLHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, epiinviabtec, obscondicoes, obsusoininterepi, prazovalidade, periodicidadetroca, higienizacao) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.epiinviabtec, NEW.obscondicoes, NEW.obsusoininterepi, NEW.prazovalidade, NEW.periodicidadetroca, NEW.higienizacao); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstepicomplauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstepicomplauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPICOMPLHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPICOMPLHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, epiinviabtec, obscondicoes, obsusoininterepi, prazovalidade, periodicidadetroca, higienizacao) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.epiinviabtec, OLD.obscondicoes, OLD.obsusoininterepi, OLD.prazovalidade, OLD.periodicidadetroca, OLD.higienizacao); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPICOMPLHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPICOMPLHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, epiinviabtec, obscondicoes, obsusoininterepi, prazovalidade, periodicidadetroca, higienizacao) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.epiinviabtec, NEW.obscondicoes, NEW.obsusoininterepi, NEW.prazovalidade, NEW.periodicidadetroca, NEW.higienizacao); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstepicomplbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstepicomplbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTEPICOMPLHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTEPICOMPLHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, epiinviabtec, obscondicoes, obsusoininterepi, prazovalidade, periodicidadetroca, higienizacao) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.epiinviabtec, OLD.obscondicoes, OLD.obsusoininterepi, OLD.prazovalidade, OLD.periodicidadetroca, OLD.higienizacao); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstfuncaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstfuncaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTFUNCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTFUNCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, codigocargo, datalaudo, codigofunccontr, datainiciocondicao, classiforgan) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.codigocargo, NEW.datalaudo, NEW.codigofunccontr, NEW.datainiciocondicao, NEW.classiforgan); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstfuncauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstfuncauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTFUNCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTFUNCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, codigocargo, datalaudo, codigofunccontr, datainiciocondicao, classiforgan) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.codigocargo, OLD.datalaudo, OLD.codigofunccontr, OLD.datainiciocondicao, OLD.classiforgan); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTFUNCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTFUNCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, codigocargo, datalaudo, codigofunccontr, datainiciocondicao, classiforgan) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.codigoambientetrab, NEW.codigocargo, NEW.datalaudo, NEW.codigofunccontr, NEW.datainiciocondicao, NEW.classiforgan); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstfuncbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstfuncbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTFUNCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTFUNCHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, codigoambientetrab, codigocargo, datalaudo, codigofunccontr, datainiciocondicao, classiforgan) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.codigoambientetrab, OLD.codigocargo, OLD.datalaudo, OLD.codigofunccontr, OLD.datainiciocondicao, OLD.classiforgan); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstresponsavelaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstresponsavelaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTRESPONSAVELHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTRESPONSAVELHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqresponsavel, responsavel, codigofunccontr, codigoterc) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.seqresponsavel, NEW.responsavel, NEW.codigofunccontr, NEW.codigoterc); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstresponsavelauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstresponsavelauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTRESPONSAVELHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTRESPONSAVELHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqresponsavel, responsavel, codigofunccontr, codigoterc) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.seqresponsavel, OLD.responsavel, OLD.codigofunccontr, OLD.codigoterc); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTRESPONSAVELHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTRESPONSAVELHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqresponsavel, responsavel, codigofunccontr, codigoterc) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datalaudo, NEW.codigoestab, NEW.codigofatorrisco, NEW.seq, NEW.seqresponsavel, NEW.responsavel, NEW.codigofunccontr, NEW.codigoterc); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="laudomedicosstresponsavelbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.laudomedicosstresponsavelbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LAUDOMEDICOSSTRESPONSAVELHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LAUDOMEDICOSSTRESPONSAVELHS(SEQHISTORICO, OPERACAO, codigoempresa, datalaudo, codigoestab, codigofatorrisco, seq, seqresponsavel, responsavel, codigofunccontr, codigoterc) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datalaudo, OLD.codigoestab, OLD.codigofatorrisco, OLD.seq, OLD.seqresponsavel, OLD.responsavel, OLD.codigofunccontr, OLD.codigoterc); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lctoativdiferencexclbif" procedure_source="CREATE OR REPLACE FUNCTION public.lctoativdiferencexclbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE&#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.IDLCTOATIVEXCL is null) THEN&#013;&#010;    new.IDLCTOATIVEXCL = NEXTVAL(&apos;gen_idlctoativdifexcl&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_idlctoativdifexcl&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_idlctoativdifexcl;&#013;&#010;END;&#013;&#010;WHILE (NEW.IDLCTOATIVEXCL &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_idlctoativdifexcl&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="lctoctbaif" procedure_source="CREATE OR REPLACE FUNCTION public.lctoctbaif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;CALL TOTALIZARSALDOCTB(new.CodigoEmpresa, new.CodigoEstab, new.ContaCtbDeb,&#010;    new.ContaCtbCred, new.DataLctoCtb, new.TipoLancamento, new.ValorLctoCtb);&#010;CALL TOTALIZARSALDOCTBHIST(new.CodigoEmpresa, new.CodigoEstab, new.ContaCtbDeb,&#010;    new.ContaCtbCred, new.DataLctoCtb, new.TipoLancamento, new.CodigoHistCtb, new.ValorLctoCtb);&#010;CALL TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa, new.CodigoEstab, new.ContaCtbDeb,&#010;    new.ContaCtbCred, new.DataLctoCtb, new.TipoLancamento, new.ValorLctoMoeda, null);&#010;RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="lctoctbauf" procedure_source="CREATE OR REPLACE FUNCTION public.lctoctbauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE&#010;aAtualizaSaldo smallint;&#010;BEGIN&#010;  aAtualizaSaldo = 0;&#010;  IF ((new.CodigoEmpresa             &lt;&gt; old.CodigoEmpresa)            or&#010;      (new.CodigoEstab               &lt;&gt; old.CodigoEstab)              or&#010;      (new.DataLctoCtb               &lt;&gt; old.DataLctoCtb)              or&#010;      (new.TipoLancamento            &lt;&gt; old.TipoLancamento)           or&#010;      (coalesce(new.ContaCtbDeb, 0)  &lt;&gt; coalesce(old.ContaCtbDeb, 0)) or&#010;      (coalesce(new.ContaCtbCred, 0) &lt;&gt; coalesce(old.ContaCtbCred, 0))) THEN&#010;    aAtualizaSaldo = 1;&#010;  END IF;&#010;  IF ((aAtualizaSaldo = 1) or (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb)) THEN&#010;CALL TOTALIZARSALDOCTB(new.CodigoEmpresa, new.CodigoEstab, new.ContaCtbDeb,&#010;    new.ContaCtbCred, new.DataLctoCtb, new.TipoLancamento, new.ValorLctoCtb);&#010;  END IF;&#010;  IF ((aAtualizaSaldo = 1) or (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb) or&#010;      (coalesce(new.CodigoHistCtb, 0) &lt;&gt; coalesce(old.CodigoHistCtb, 0))) THEN&#010;CALL TOTALIZARSALDOCTBHIST(new.CodigoEmpresa, new.CodigoEstab, new.ContaCtbDeb,&#010;    new.ContaCtbCred, new.DataLctoCtb, new.TipoLancamento, new.CodigoHistCtb, new.ValorLctoCtb);&#010;  END IF;&#010;  IF ((aAtualizaSaldo = 1) or (coalesce(new.ValorLctoMoeda, 0) &lt;&gt; coalesce(old.ValorLctoMoeda, 0))) THEN&#010;CALL TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa, new.CodigoEstab, new.ContaCtbDeb,&#010;    new.ContaCtbCred, new.DataLctoCtb, new.TipoLancamento, new.ValorLctoMoeda, null);&#010;  END IF;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="lctoctbbdf" procedure_source="CREATE OR REPLACE FUNCTION public.lctoctbbdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;CALL SUBTRAIRSALDOCTB(old.CodigoEmpresa, old.CodigoEstab, old.ContaCtbDeb,&#010;    old.ContaCtbCred, old.DataLctoCtb, old.TipoLancamento, old.ValorLctoCtb);&#010;CALL SUBTRAIRSALDOCTBHIST(old.CodigoEmpresa, old.CodigoEstab, old.ContaCtbDeb,&#010;    old.ContaCtbCred, old.DataLctoCtb, old.TipoLancamento, old.CodigoHistCtb, old.ValorLctoCtb);&#010;CALL SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa, old.CodigoEstab, old.ContaCtbDeb,&#010;    old.ContaCtbCred, old.DataLctoCtb, old.TipoLancamento, old.ValorLctoMoeda, null);&#010;RETURN old;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="lctoctbbichavef" procedure_source="CREATE OR REPLACE FUNCTION public.lctoctbbichavef()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;&#010;DECLARE&#010;tmp integer;&#010;nomegen varchar(100);&#010;BEGIN&#010;  nomegen = &apos;dyn_genchavelctoctb_&apos;||New.CODIGOEMPRESA;&#010;  IF (NEW.CHAVELCTOCTB IS NULL) THEN&#010;EXECUTE &apos;SELECT nextval(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#010;    NEW.CHAVELCTOCTB = tmp;&#010;  ELSE&#010;BEGIN&#010;EXECUTE &apos;SELECT CURRVAL(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#010;EXCEPTION WHEN OTHERS THEN&#010;EXECUTE &apos;SELECT last_value FROM &apos;||nomegen INTO tmp;&#010;END;&#010;    WHILE (NEW.CHAVELCTOCTB  &gt; tmp) LOOP &#010;EXECUTE &apos;SELECT nextval(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#010;END LOOP;&#010;  END IF;&#010;  RETURN NEW;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="lctoctbbif" procedure_source="CREATE OR REPLACE FUNCTION public.lctoctbbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;BEGIN&#013;&#010;  IF ((new.TipoLancamento is null) OR (NOT(new.TipoLancamento IN (&apos;LN&apos;, &apos;LS&apos;, &apos;LF&apos;)))) THEN&#013;&#010;    new.TipoLancamento = &apos;LN&apos;;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="lctoctbbuf" procedure_source="CREATE OR REPLACE FUNCTION public.lctoctbbuf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE&#010;aAtualizaSaldo smallint;&#010;BEGIN&#010;  aAtualizaSaldo = 0;&#010;  IF ((new.CodigoEmpresa             &lt;&gt; old.CodigoEmpresa)            OR&#010;      (new.CodigoEstab               &lt;&gt; old.CodigoEstab)              OR&#010;      (new.DataLctoCtb               &lt;&gt; old.DataLctoCtb)              OR&#010;      (new.TipoLancamento            &lt;&gt; old.TipoLancamento)           OR&#010;      (coalesce(new.ContaCtbDeb, 0)  &lt;&gt; coalesce(old.ContaCtbDeb, 0)) OR&#010;      (coalesce(new.ContaCtbCred, 0) &lt;&gt; coalesce(old.ContaCtbCred, 0))) THEN&#010;    aAtualizaSaldo = 1;&#010;  END IF;&#010;  IF ((aAtualizaSaldo = 1) or (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb)) THEN&#010;CALL SUBTRAIRSALDOCTB(old.CodigoEmpresa, old.CodigoEstab, old.ContaCtbDeb,&#010;    old.ContaCtbCred, old.DataLctoCtb, old.TipoLancamento, old.ValorLctoCtb);&#010;  END IF;&#010;  IF ((aAtualizaSaldo = 1) OR (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb) OR&#010;      (coalesce(new.CodigoHistCtb, 0) &lt;&gt; coalesce(old.CodigoHistCtb, 0)))  THEN&#010;    CALL SUBTRAIRSALDOCTBHIST(old.CodigoEmpresa, old.CodigoEstab, old.ContaCtbDeb,&#010;    old.ContaCtbCred, old.DataLctoCtb, old.TipoLancamento, old.CodigoHistCtb, old.ValorLctoCtb);&#010;  END IF;&#010;  IF ((aAtualizaSaldo = 1) OR (coalesce(new.ValorLctoMoeda, 0) &lt;&gt; coalesce(old.ValorLctoMoeda, 0))) THEN&#010;    CALL SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa, old.CodigoEstab, old.ContaCtbDeb,&#010;    old.ContaCtbCred, old.DataLctoCtb, old.TipoLancamento, old.ValorLctoMoeda, null);&#010;  END IF;&#010;  RETURN NEW;&#010;END;&#010;$function$&#010;"/>
<ROW pro_key="lctoctbexcluidobif" procedure_source="CREATE OR REPLACE FUNCTION public.lctoctbexcluidobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE&#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.IDLCTOCTBEXCL is null) THEN&#013;&#010;    new.IDLCTOCTBEXCL = NEXTVAL(&apos;gen_idlctoctbexcl&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_idlctoctbexcl&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_idlctoctbexcl;&#013;&#010;END;&#013;&#010;WHILE (NEW.IDLCTOCTBEXCL &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_idlctoctbexcl&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="lctodocumentofiscalbif" procedure_source="CREATE OR REPLACE FUNCTION public.lctodocumentofiscalbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGODOCUMENTOFISCAL IS NULL) THEN&#013;&#010;    NEW.CODIGODOCUMENTOFISCAL = NEXTVAL(&apos;gen_codigodocumentofiscal&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigodocumentofiscal&apos;) INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO tmp FROM gen_codigodocumentofiscal;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGODOCUMENTOFISCAL &gt; tmp) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigodocumentofiscal&apos;) INTO tmp;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="lctofisentbif" procedure_source="CREATE OR REPLACE FUNCTION public.lctofisentbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;tmp int8;&#013;&#010;nomegen varchar(100);&#013;&#010;BEGIN&#013;&#010;nomegen = &apos;DYN_GENCHAVELCTOFISENT_&apos;||New.CODIGOEMPRESA;&#013;&#010;IF (NEW.CHAVELCTOFISENT IS NULL) THEN&#013;&#010;EXECUTE &apos;SELECT nextval(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#013;&#010;NEW.CHAVELCTOFISENT = tmp;&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;EXECUTE &apos;SELECT CURRVAL(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;EXECUTE &apos;SELECT last_value FROM &apos;||nomegen INTO tmp;&#013;&#010;END;&#013;&#010;WHILE (NEW.CHAVELCTOFISENT &gt; tmp) LOOP&#013;&#010;EXECUTE &apos;SELECT nextval(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;&#013;&#010;$function$&#010;"/>
<ROW pro_key="lctofissaibif" procedure_source="CREATE OR REPLACE FUNCTION public.lctofissaibif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;tmp int8;&#013;&#010;nomegen varchar(100);&#013;&#010;BEGIN&#013;&#010;nomegen = &apos;DYN_GENCHAVELCTOFISSAI_&apos;||New.CODIGOEMPRESA;&#013;&#010;IF (NEW.CHAVELCTOFISSAI IS NULL) THEN&#013;&#010;EXECUTE &apos;SELECT nextval(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#013;&#010;NEW.CHAVELCTOFISSAI = tmp;&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;EXECUTE &apos;SELECT CURRVAL(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;EXECUTE &apos;SELECT last_value FROM &apos;||nomegen INTO tmp;&#013;&#010;END;&#013;&#010;WHILE (NEW.CHAVELCTOFISSAI &gt; tmp) LOOP&#013;&#010;EXECUTE &apos;SELECT nextval(&apos;&apos;&apos;||nomegen||&apos;&apos;&apos;)&apos; INTO tmp;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;&#013;&#010;$function$&#010;"/>
<ROW pro_key="lctogerexcluidobif" procedure_source="CREATE OR REPLACE FUNCTION public.lctogerexcluidobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.IDLCTOGEREXCL is null) THEN&#013;&#010;    new.IDLCTOGEREXCL = nextval(&apos;gen_idlctogerexcl&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_idlctogerexcl&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_idlctogerexcl;&#013;&#010;END;&#013;&#010;WHILE (NEW.IDLCTOGEREXCL &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_idlctogerexcl&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="loggeralbif" procedure_source="CREATE OR REPLACE FUNCTION public.loggeralbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i INTEGER;&#013;&#010;BEGIN&#013;&#010;  IF (new.IDLOG is null) then&#013;&#010;    new.IDLOG = NEXTVAL(&apos;genlog&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;genlog&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM genlog;&#013;&#010;END;&#013;&#010;WHILE (NEW.IDLOG &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;genlog&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  IF (new.DATAHORAINICIO is null) THEN&#013;&#010;    new.DATAHORAINICIO = current_timestamp;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;end; &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, codigolotacao, descrlotacao, tipolotacao, codigooutemp, codigotabgps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.datainicial, NEW.codigolotacao, NEW.descrlotacao, NEW.tipolotacao, NEW.codigooutemp, NEW.codigotabgps, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, codigolotacao, descrlotacao, tipolotacao, codigooutemp, codigotabgps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.datainicial, OLD.codigolotacao, OLD.descrlotacao, OLD.tipolotacao, OLD.codigooutemp, OLD.codigotabgps, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, codigolotacao, descrlotacao, tipolotacao, codigooutemp, codigotabgps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.datainicial, NEW.codigolotacao, NEW.descrlotacao, NEW.tipolotacao, NEW.codigooutemp, NEW.codigotabgps, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, datainicial, codigolotacao, descrlotacao, tipolotacao, codigooutemp, codigotabgps, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.datainicial, OLD.codigolotacao, OLD.descrlotacao, OLD.tipolotacao, OLD.codigooutemp, OLD.codigotabgps, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaoempresaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaoempresaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigomatrizrelat, codigolotacao, datainicial, status) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigomatrizrelat, NEW.codigolotacao, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaoempresaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaoempresaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigomatrizrelat, codigolotacao, datainicial, status) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigomatrizrelat, OLD.codigolotacao, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigomatrizrelat, codigolotacao, datainicial, status) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigomatrizrelat, NEW.codigolotacao, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaoempresabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaoempresabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigomatrizrelat, codigolotacao, datainicial, status) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigomatrizrelat, OLD.codigolotacao, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaotributariaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaotributariaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIAHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, codigooutemp, descricaolotacao, codigomatrizrelat) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.codigooutemp, NEW.descricaolotacao, NEW.codigomatrizrelat); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaotributariaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaotributariaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIAHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, codigooutemp, descricaolotacao, codigomatrizrelat) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.codigooutemp, OLD.descricaolotacao, OLD.codigomatrizrelat); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIAHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, codigooutemp, descricaolotacao, codigomatrizrelat) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.codigooutemp, NEW.descricaolotacao, NEW.codigomatrizrelat); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaotributariabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaotributariabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIAHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, codigooutemp, descricaolotacao, codigomatrizrelat) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.codigooutemp, OLD.descricaolotacao, OLD.codigomatrizrelat); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaotributariadetaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaotributariadetaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIADETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIADETHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, convenios, codigoprocessojudadm, codigoterceiros, percentualterceiro) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.convenios, NEW.codigoprocessojudadm, NEW.codigoterceiros, NEW.percentualterceiro); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaotributariadetauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaotributariadetauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIADETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIADETHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, convenios, codigoprocessojudadm, codigoterceiros, percentualterceiro) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.convenios, OLD.codigoprocessojudadm, OLD.codigoterceiros, OLD.percentualterceiro); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIADETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIADETHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, convenios, codigoprocessojudadm, codigoterceiros, percentualterceiro) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.convenios, NEW.codigoprocessojudadm, NEW.codigoterceiros, NEW.percentualterceiro); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="lotacaotributariadetbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.lotacaotributariadetbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;LOTACAOTRIBUTARIADETHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO LOTACAOTRIBUTARIADETHS(SEQHISTORICO, OPERACAO, codigoempresa, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, convenios, codigoprocessojudadm, codigoterceiros, percentualterceiro) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.convenios, OLD.codigoprocessojudadm, OLD.codigoterceiros, OLD.percentualterceiro); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="municipioaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.municipioaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;MUNICIPIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO MUNICIPIOHS(SEQHISTORICO, OPERACAO, siglaestado, codigomunic, nomemunic, abreviaturamunic, codigoestad, codigofederal, codigorais, codigosecund, mascinscrmunic, mascativmunic, cepmunic, simplesfederal, aliqsimplesfederal, valorminissretido, taxarecissqn, sistemaiss, urlwsdlsistemaiss, versaoiss, valorminreciss, codigomunicipio, codigocfgnfse, sistemanf, integrarnfseapiterc, configuracaonfseduplicas) &#013;&#010;  VALUES (GEN, 1, NEW.siglaestado, NEW.codigomunic, NEW.nomemunic, NEW.abreviaturamunic, NEW.codigoestad, NEW.codigofederal, NEW.codigorais, NEW.codigosecund, NEW.mascinscrmunic, NEW.mascativmunic, NEW.cepmunic, NEW.simplesfederal, NEW.aliqsimplesfederal, NEW.valorminissretido, NEW.taxarecissqn, NEW.sistemaiss, NEW.urlwsdlsistemaiss, NEW.versaoiss, NEW.valorminreciss, NEW.codigomunicipio, NEW.codigocfgnfse, NEW.sistemanf, NEW.integrarnfseapiterc, NEW.configuracaonfseduplicas); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="municipioauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.municipioauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;MUNICIPIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO MUNICIPIOHS(SEQHISTORICO, OPERACAO, siglaestado, codigomunic, nomemunic, abreviaturamunic, codigoestad, codigofederal, codigorais, codigosecund, mascinscrmunic, mascativmunic, cepmunic, simplesfederal, aliqsimplesfederal, valorminissretido, taxarecissqn, sistemaiss, urlwsdlsistemaiss, versaoiss, valorminreciss, codigomunicipio, codigocfgnfse, sistemanf, integrarnfseapiterc, configuracaonfseduplicas) &#013;&#010;  VALUES (GEN, 2, OLD.siglaestado, OLD.codigomunic, OLD.nomemunic, OLD.abreviaturamunic, OLD.codigoestad, OLD.codigofederal, OLD.codigorais, OLD.codigosecund, OLD.mascinscrmunic, OLD.mascativmunic, OLD.cepmunic, OLD.simplesfederal, OLD.aliqsimplesfederal, OLD.valorminissretido, OLD.taxarecissqn, OLD.sistemaiss, OLD.urlwsdlsistemaiss, OLD.versaoiss, OLD.valorminreciss, OLD.codigomunicipio, OLD.codigocfgnfse, OLD.sistemanf, OLD.integrarnfseapiterc, OLD.configuracaonfseduplicas); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;MUNICIPIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO MUNICIPIOHS(SEQHISTORICO, OPERACAO, siglaestado, codigomunic, nomemunic, abreviaturamunic, codigoestad, codigofederal, codigorais, codigosecund, mascinscrmunic, mascativmunic, cepmunic, simplesfederal, aliqsimplesfederal, valorminissretido, taxarecissqn, sistemaiss, urlwsdlsistemaiss, versaoiss, valorminreciss, codigomunicipio, codigocfgnfse, sistemanf, integrarnfseapiterc, configuracaonfseduplicas) &#013;&#010;  VALUES (GEN, 3, NEW.siglaestado, NEW.codigomunic, NEW.nomemunic, NEW.abreviaturamunic, NEW.codigoestad, NEW.codigofederal, NEW.codigorais, NEW.codigosecund, NEW.mascinscrmunic, NEW.mascativmunic, NEW.cepmunic, NEW.simplesfederal, NEW.aliqsimplesfederal, NEW.valorminissretido, NEW.taxarecissqn, NEW.sistemaiss, NEW.urlwsdlsistemaiss, NEW.versaoiss, NEW.valorminreciss, NEW.codigomunicipio, NEW.codigocfgnfse, NEW.sistemanf, NEW.integrarnfseapiterc, NEW.configuracaonfseduplicas); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="municipiobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.municipiobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;MUNICIPIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO MUNICIPIOHS(SEQHISTORICO, OPERACAO, siglaestado, codigomunic, nomemunic, abreviaturamunic, codigoestad, codigofederal, codigorais, codigosecund, mascinscrmunic, mascativmunic, cepmunic, simplesfederal, aliqsimplesfederal, valorminissretido, taxarecissqn, sistemaiss, urlwsdlsistemaiss, versaoiss, valorminreciss, codigomunicipio, codigocfgnfse, sistemanf, integrarnfseapiterc, configuracaonfseduplicas) &#013;&#010;  VALUES (GEN, 4, OLD.siglaestado, OLD.codigomunic, OLD.nomemunic, OLD.abreviaturamunic, OLD.codigoestad, OLD.codigofederal, OLD.codigorais, OLD.codigosecund, OLD.mascinscrmunic, OLD.mascativmunic, OLD.cepmunic, OLD.simplesfederal, OLD.aliqsimplesfederal, OLD.valorminissretido, OLD.taxarecissqn, OLD.sistemaiss, OLD.urlwsdlsistemaiss, OLD.versaoiss, OLD.valorminreciss, OLD.codigomunicipio, OLD.codigocfgnfse, OLD.sistemanf, OLD.integrarnfseapiterc, OLD.configuracaonfseduplicas); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="organogramalotacaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.organogramalotacaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ORGANOGRAMALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGANOGRAMALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, classiforgan, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal, atividadesimples) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoestab, NEW.classiforgan, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.competfinal, NEW.atividadesimples); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="organogramalotacaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.organogramalotacaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ORGANOGRAMALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGANOGRAMALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, classiforgan, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal, atividadesimples) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoestab, OLD.classiforgan, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.competfinal, OLD.atividadesimples); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;ORGANOGRAMALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGANOGRAMALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, classiforgan, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal, atividadesimples) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoestab, NEW.classiforgan, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.competfinal, NEW.atividadesimples); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="organogramalotacaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.organogramalotacaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;ORGANOGRAMALOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGANOGRAMALOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoestab, classiforgan, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, competfinal, atividadesimples) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoestab, OLD.classiforgan, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.competfinal, OLD.atividadesimples); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="orgaoemissoraihsf" procedure_source="CREATE OR REPLACE FUNCTION public.orgaoemissoraihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ORGAOEMISSORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGAOEMISSORHS(SEQHISTORICO, OPERACAO, codigoorgaoemissor, siglaorgaoemissor, descrorgaoemissor) &#013;&#010;  VALUES (GEN, 1, NEW.codigoorgaoemissor, NEW.siglaorgaoemissor, NEW.descrorgaoemissor); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="orgaoemissorauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.orgaoemissorauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ORGAOEMISSORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGAOEMISSORHS(SEQHISTORICO, OPERACAO, codigoorgaoemissor, siglaorgaoemissor, descrorgaoemissor) &#013;&#010;  VALUES (GEN, 2, OLD.codigoorgaoemissor, OLD.siglaorgaoemissor, OLD.descrorgaoemissor); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ORGAOEMISSORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGAOEMISSORHS(SEQHISTORICO, OPERACAO, codigoorgaoemissor, siglaorgaoemissor, descrorgaoemissor) &#013;&#010;  VALUES (GEN, 3, NEW.codigoorgaoemissor, NEW.siglaorgaoemissor, NEW.descrorgaoemissor); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="orgaoemissorbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.orgaoemissorbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;ORGAOEMISSORHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO ORGAOEMISSORHS(SEQHISTORICO, OPERACAO, codigoorgaoemissor, siglaorgaoemissor, descrorgaoemissor) &#013;&#010;  VALUES (GEN, 4, OLD.codigoorgaoemissor, OLD.siglaorgaoemissor, OLD.descrorgaoemissor); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempempaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempempaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;OUTRAEMPEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, datainicial, tipooutemp, tipoobra, tipoempreitada, possuigps, codigoimposto, variacaoimposto, codigotabgps, codigoestabctb, codigotabctb, codigolocalctb, dataencerativ, gpsrecebimentos, codigotabferiado, registroans, outrasinf, codigoselecao, codigoativfederal, datainicioativ, inscrfedprestadorserv, tipoinscrcontrat, inscrfedcontrat, tipoinscrpropriet, inscrfedpropriet, indmenaprendiz, codigoprocessojudadmmenapr, menoraprendizentid, dataopcaodesoner, tipocontroleponto, tipoalteracaoesocial, retinsspgtooutemp, retinssnfemitidaoutemp, centrocustopadrao) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigooutemp, NEW.datainicial, NEW.tipooutemp, NEW.tipoobra, NEW.tipoempreitada, NEW.possuigps, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigotabgps, NEW.codigoestabctb, NEW.codigotabctb, NEW.codigolocalctb, NEW.dataencerativ, NEW.gpsrecebimentos, NEW.codigotabferiado, NEW.registroans, NEW.outrasinf, NEW.codigoselecao, NEW.codigoativfederal, NEW.datainicioativ, NEW.inscrfedprestadorserv, NEW.tipoinscrcontrat, NEW.inscrfedcontrat, NEW.tipoinscrpropriet, NEW.inscrfedpropriet, NEW.indmenaprendiz, NEW.codigoprocessojudadmmenapr, NEW.menoraprendizentid, NEW.dataopcaodesoner, NEW.tipocontroleponto, NEW.tipoalteracaoesocial, NEW.retinsspgtooutemp, NEW.retinssnfemitidaoutemp, NEW.centrocustopadrao); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempempauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempempauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;OUTRAEMPEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, datainicial, tipooutemp, tipoobra, tipoempreitada, possuigps, codigoimposto, variacaoimposto, codigotabgps, codigoestabctb, codigotabctb, codigolocalctb, dataencerativ, gpsrecebimentos, codigotabferiado, registroans, outrasinf, codigoselecao, codigoativfederal, datainicioativ, inscrfedprestadorserv, tipoinscrcontrat, inscrfedcontrat, tipoinscrpropriet, inscrfedpropriet, indmenaprendiz, codigoprocessojudadmmenapr, menoraprendizentid, dataopcaodesoner, tipocontroleponto, tipoalteracaoesocial, retinsspgtooutemp, retinssnfemitidaoutemp, centrocustopadrao) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigooutemp, OLD.datainicial, OLD.tipooutemp, OLD.tipoobra, OLD.tipoempreitada, OLD.possuigps, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigotabgps, OLD.codigoestabctb, OLD.codigotabctb, OLD.codigolocalctb, OLD.dataencerativ, OLD.gpsrecebimentos, OLD.codigotabferiado, OLD.registroans, OLD.outrasinf, OLD.codigoselecao, OLD.codigoativfederal, OLD.datainicioativ, OLD.inscrfedprestadorserv, OLD.tipoinscrcontrat, OLD.inscrfedcontrat, OLD.tipoinscrpropriet, OLD.inscrfedpropriet, OLD.indmenaprendiz, OLD.codigoprocessojudadmmenapr, OLD.menoraprendizentid, OLD.dataopcaodesoner, OLD.tipocontroleponto, OLD.tipoalteracaoesocial, OLD.retinsspgtooutemp, OLD.retinssnfemitidaoutemp, OLD.centrocustopadrao); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;OUTRAEMPEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, datainicial, tipooutemp, tipoobra, tipoempreitada, possuigps, codigoimposto, variacaoimposto, codigotabgps, codigoestabctb, codigotabctb, codigolocalctb, dataencerativ, gpsrecebimentos, codigotabferiado, registroans, outrasinf, codigoselecao, codigoativfederal, datainicioativ, inscrfedprestadorserv, tipoinscrcontrat, inscrfedcontrat, tipoinscrpropriet, inscrfedpropriet, indmenaprendiz, codigoprocessojudadmmenapr, menoraprendizentid, dataopcaodesoner, tipocontroleponto, tipoalteracaoesocial, retinsspgtooutemp, retinssnfemitidaoutemp, centrocustopadrao) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigooutemp, NEW.datainicial, NEW.tipooutemp, NEW.tipoobra, NEW.tipoempreitada, NEW.possuigps, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigotabgps, NEW.codigoestabctb, NEW.codigotabctb, NEW.codigolocalctb, NEW.dataencerativ, NEW.gpsrecebimentos, NEW.codigotabferiado, NEW.registroans, NEW.outrasinf, NEW.codigoselecao, NEW.codigoativfederal, NEW.datainicioativ, NEW.inscrfedprestadorserv, NEW.tipoinscrcontrat, NEW.inscrfedcontrat, NEW.tipoinscrpropriet, NEW.inscrfedpropriet, NEW.indmenaprendiz, NEW.codigoprocessojudadmmenapr, NEW.menoraprendizentid, NEW.dataopcaodesoner, NEW.tipocontroleponto, NEW.tipoalteracaoesocial, NEW.retinsspgtooutemp, NEW.retinssnfemitidaoutemp, NEW.centrocustopadrao); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempempbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempempbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;OUTRAEMPEMPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, datainicial, tipooutemp, tipoobra, tipoempreitada, possuigps, codigoimposto, variacaoimposto, codigotabgps, codigoestabctb, codigotabctb, codigolocalctb, dataencerativ, gpsrecebimentos, codigotabferiado, registroans, outrasinf, codigoselecao, codigoativfederal, datainicioativ, inscrfedprestadorserv, tipoinscrcontrat, inscrfedcontrat, tipoinscrpropriet, inscrfedpropriet, indmenaprendiz, codigoprocessojudadmmenapr, menoraprendizentid, dataopcaodesoner, tipocontroleponto, tipoalteracaoesocial, retinsspgtooutemp, retinssnfemitidaoutemp, centrocustopadrao) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigooutemp, OLD.datainicial, OLD.tipooutemp, OLD.tipoobra, OLD.tipoempreitada, OLD.possuigps, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigotabgps, OLD.codigoestabctb, OLD.codigotabctb, OLD.codigolocalctb, OLD.dataencerativ, OLD.gpsrecebimentos, OLD.codigotabferiado, OLD.registroans, OLD.outrasinf, OLD.codigoselecao, OLD.codigoativfederal, OLD.datainicioativ, OLD.inscrfedprestadorserv, OLD.tipoinscrcontrat, OLD.inscrfedcontrat, OLD.tipoinscrpropriet, OLD.inscrfedpropriet, OLD.indmenaprendiz, OLD.codigoprocessojudadmmenapr, OLD.menoraprendizentid, OLD.dataopcaodesoner, OLD.tipocontroleponto, OLD.tipoalteracaoesocial, OLD.retinsspgtooutemp, OLD.retinssnfemitidaoutemp, OLD.centrocustopadrao); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempemplotacaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempemplotacaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;OUTRAEMPEMPLOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPLOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, atividadesimples) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigooutemp, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.atividadesimples); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempemplotacaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempemplotacaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;OUTRAEMPEMPLOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPLOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, atividadesimples) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigooutemp, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.atividadesimples); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;OUTRAEMPEMPLOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPLOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, atividadesimples) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigooutemp, NEW.origemlotacao, NEW.codigofpas, NEW.tipolotacao, NEW.codigolotacao, NEW.competinicial, NEW.atividadesimples); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempemplotacaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempemplotacaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;OUTRAEMPEMPLOTACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPEMPLOTACAOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigooutemp, origemlotacao, codigofpas, tipolotacao, codigolotacao, competinicial, atividadesimples) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigooutemp, OLD.origemlotacao, OLD.codigofpas, OLD.tipolotacao, OLD.codigolotacao, OLD.competinicial, OLD.atividadesimples); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempresaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempresaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;OUTRAEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPRESAHS(SEQHISTORICO, OPERACAO, codigooutemp, datainicial, nomeoutemp, fantoutemp, codigotipolograd, enderoutemp, numeroender, complender, bairrooutemp, siglaestado, codigomunic, cep, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, tipoinscr, inscrfederal, atividadeeconomica, porteemp, servico, tipoalteracaoesocial, domiciliadaext) &#013;&#010;  VALUES (GEN, 1, NEW.codigooutemp, NEW.datainicial, NEW.nomeoutemp, NEW.fantoutemp, NEW.codigotipolograd, NEW.enderoutemp, NEW.numeroender, NEW.complender, NEW.bairrooutemp, NEW.siglaestado, NEW.codigomunic, NEW.cep, NEW.dddfone, NEW.numerofone, NEW.dddfax, NEW.numerofax, NEW.endereletr, NEW.paginainter, NEW.tipoinscr, NEW.inscrfederal, NEW.atividadeeconomica, NEW.porteemp, NEW.servico, NEW.tipoalteracaoesocial, NEW.domiciliadaext); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempresaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempresaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;OUTRAEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPRESAHS(SEQHISTORICO, OPERACAO, codigooutemp, datainicial, nomeoutemp, fantoutemp, codigotipolograd, enderoutemp, numeroender, complender, bairrooutemp, siglaestado, codigomunic, cep, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, tipoinscr, inscrfederal, atividadeeconomica, porteemp, servico, tipoalteracaoesocial, domiciliadaext) &#013;&#010;  VALUES (GEN, 2, OLD.codigooutemp, OLD.datainicial, OLD.nomeoutemp, OLD.fantoutemp, OLD.codigotipolograd, OLD.enderoutemp, OLD.numeroender, OLD.complender, OLD.bairrooutemp, OLD.siglaestado, OLD.codigomunic, OLD.cep, OLD.dddfone, OLD.numerofone, OLD.dddfax, OLD.numerofax, OLD.endereletr, OLD.paginainter, OLD.tipoinscr, OLD.inscrfederal, OLD.atividadeeconomica, OLD.porteemp, OLD.servico, OLD.tipoalteracaoesocial, OLD.domiciliadaext); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;OUTRAEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPRESAHS(SEQHISTORICO, OPERACAO, codigooutemp, datainicial, nomeoutemp, fantoutemp, codigotipolograd, enderoutemp, numeroender, complender, bairrooutemp, siglaestado, codigomunic, cep, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, tipoinscr, inscrfederal, atividadeeconomica, porteemp, servico, tipoalteracaoesocial, domiciliadaext) &#013;&#010;  VALUES (GEN, 3, NEW.codigooutemp, NEW.datainicial, NEW.nomeoutemp, NEW.fantoutemp, NEW.codigotipolograd, NEW.enderoutemp, NEW.numeroender, NEW.complender, NEW.bairrooutemp, NEW.siglaestado, NEW.codigomunic, NEW.cep, NEW.dddfone, NEW.numerofone, NEW.dddfax, NEW.numerofax, NEW.endereletr, NEW.paginainter, NEW.tipoinscr, NEW.inscrfederal, NEW.atividadeeconomica, NEW.porteemp, NEW.servico, NEW.tipoalteracaoesocial, NEW.domiciliadaext); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="outraempresabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.outraempresabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;OUTRAEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO OUTRAEMPRESAHS(SEQHISTORICO, OPERACAO, codigooutemp, datainicial, nomeoutemp, fantoutemp, codigotipolograd, enderoutemp, numeroender, complender, bairrooutemp, siglaestado, codigomunic, cep, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, tipoinscr, inscrfederal, atividadeeconomica, porteemp, servico, tipoalteracaoesocial, domiciliadaext) &#013;&#010;  VALUES (GEN, 4, OLD.codigooutemp, OLD.datainicial, OLD.nomeoutemp, OLD.fantoutemp, OLD.codigotipolograd, OLD.enderoutemp, OLD.numeroender, OLD.complender, OLD.bairrooutemp, OLD.siglaestado, OLD.codigomunic, OLD.cep, OLD.dddfone, OLD.numerofone, OLD.dddfax, OLD.numerofax, OLD.endereletr, OLD.paginainter, OLD.tipoinscr, OLD.inscrfederal, OLD.atividadeeconomica, OLD.porteemp, OLD.servico, OLD.tipoalteracaoesocial, OLD.domiciliadaext); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="paisaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.paisaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;PAISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PAISHS(SEQHISTORICO, OPERACAO, codigopais, nomepais, codigopaisnis, codigopaisrs, codigopaisesocial, codigopaissped, codigopaisiso) &#013;&#010;  VALUES (GEN, 1, NEW.codigopais, NEW.nomepais, NEW.codigopaisnis, NEW.codigopaisrs, NEW.codigopaisesocial, NEW.codigopaissped, NEW.codigopaisiso); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="paisauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.paisauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;PAISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PAISHS(SEQHISTORICO, OPERACAO, codigopais, nomepais, codigopaisnis, codigopaisrs, codigopaisesocial, codigopaissped, codigopaisiso) &#013;&#010;  VALUES (GEN, 2, OLD.codigopais, OLD.nomepais, OLD.codigopaisnis, OLD.codigopaisrs, OLD.codigopaisesocial, OLD.codigopaissped, OLD.codigopaisiso); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;PAISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PAISHS(SEQHISTORICO, OPERACAO, codigopais, nomepais, codigopaisnis, codigopaisrs, codigopaisesocial, codigopaissped, codigopaisiso) &#013;&#010;  VALUES (GEN, 3, NEW.codigopais, NEW.nomepais, NEW.codigopaisnis, NEW.codigopaisrs, NEW.codigopaisesocial, NEW.codigopaissped, NEW.codigopaisiso); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="paisbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.paisbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;PAISHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PAISHS(SEQHISTORICO, OPERACAO, codigopais, nomepais, codigopaisnis, codigopaisrs, codigopaisesocial, codigopaissped, codigopaisiso) &#013;&#010;  VALUES (GEN, 4, OLD.codigopais, OLD.nomepais, OLD.codigopaisnis, OLD.codigopaisrs, OLD.codigopaisesocial, OLD.codigopaissped, OLD.codigopaisiso); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="patbembif" procedure_source="CREATE OR REPLACE FUNCTION public.patbembif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.CODIGOBEM is null) THEN&#013;&#010;    new.CODIGOBEM = NEXTVAL(&apos;gen_codigobem&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigobem&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_codigobem;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOBEM &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigobem&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;end; &#013;&#010;$function$&#010;"/>
<ROW pro_key="patbemcontacontabilbif" procedure_source="CREATE OR REPLACE FUNCTION public.patbemcontacontabilbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.CODIGOBEMCONTACONTABIL is null) THEN&#013;&#010;    new.CODIGOBEMCONTACONTABIL = NEXTVAL(&apos;gen_codigobemcontacontabil&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigobemcontacontabil&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_codigobemcontacontabil;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOBEMCONTACONTABIL &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigobemcontacontabil&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="patcfgbembif" procedure_source="CREATE OR REPLACE FUNCTION public.patcfgbembif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.CODIGOCFGBEM is null) THEN&#013;&#010;    new.CODIGOCFGBEM = NEXTVAL(&apos;gen_codigocfgbem&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigocfgbem&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_codigocfgbem;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOCFGBEM &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigocfgbem&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="patenccontacontabilbif" procedure_source="CREATE OR REPLACE FUNCTION public.patenccontacontabilbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOENCCONTACONTABIL IS NULL) THEN&#013;&#010;    NEW.CODIGOENCCONTACONTABIL = NEXTVAL(&apos;gen_codigoenccontacontabil&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigoenccontacontabil&apos;) INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO tmp FROM gen_codigoenccontacontabil;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOENCCONTACONTABIL &gt; tmp) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigoenccontacontabil&apos;) INTO tmp;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="patgrupobif" procedure_source="CREATE OR REPLACE FUNCTION public.patgrupobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOGRUPO IS NULL) THEN&#013;&#010;    NEW.CODIGOGRUPO = NEXTVAL(&apos;gen_codigogrupo&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigogrupo&apos;) INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO tmp FROM gen_codigogrupo;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOGRUPO &gt; tmp) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigogrupo&apos;) INTO tmp;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="patgrupodetalhebif" procedure_source="CREATE OR REPLACE FUNCTION public.patgrupodetalhebif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGODETALHE IS NULL) THEN&#013;&#010;    NEW.CODIGODETALHE = NEXTVAL(&apos;gen_codigodetalhe&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigodetalhe&apos;) INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO tmp FROM gen_codigodetalhe;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGODETALHE &gt; tmp) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigodetalhe&apos;) INTO tmp;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="pathistoricoconversaobif" procedure_source="CREATE OR REPLACE FUNCTION public.pathistoricoconversaobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOHISTORICOCONVERSAO IS NULL) THEN&#013;&#010;    NEW.CODIGOHISTORICOCONVERSAO = NEXTVAL(&apos;gen_codigohistoricoconversao&apos;);&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigohistoricoconversao&apos;) INTO tmp;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO tmp FROM gen_codigohistoricoconversao;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOHISTORICOCONVERSAO &gt; tmp) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigohistoricoconversao&apos;) INTO tmp;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END; &#013;&#010;$function$&#010;"/>
<ROW pro_key="pessoabif" procedure_source="CREATE OR REPLACE FUNCTION public.pessoabif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE &#013;&#010;i Numeric(14,0); &#013;&#010;BEGIN &#013;&#010;IF (new.CODIGOPESSOA is null) THEN &#013;&#010;new.CODIGOPESSOA = NEXTVAL(&apos;gen_codigopessoa&apos;);/**/ &#013;&#010;ELSE &#013;&#010;BEGIN &#013;&#010;SELECT CURRVAL(&apos;gen_codigopessoa&apos;) INTO i; &#013;&#010;EXCEPTION WHEN OTHERS THEN &#013;&#010;SELECT last_value INTO i FROM gen_codigopessoa; &#013;&#010;END; &#013;&#010;WHILE (NEW.CODIGOPESSOA &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigopessoa&apos;) INTO i; &#013;&#010;END LOOP; &#013;&#010;END IF; &#013;&#010;RETURN NEW; &#013;&#010;end;&#013;&#010;$function$&#010;"/>
<ROW pro_key="processojudadmaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.processojudadmaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;PROCESSOJUDADMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoprocesso, datainicial, descricaojudadm, codigoprocessojudadm, numeroproc, datainicialval, datafinalval, enderprocessojudadm, resumoprocessojudadm, ufvara, codigomunicvara, idvara, tipoalteracaoesocial, observacao, matproc, autoria) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.tipoprocesso, NEW.datainicial, NEW.descricaojudadm, NEW.codigoprocessojudadm, NEW.numeroproc, NEW.datainicialval, NEW.datafinalval, NEW.enderprocessojudadm, NEW.resumoprocessojudadm, NEW.ufvara, NEW.codigomunicvara, NEW.idvara, NEW.tipoalteracaoesocial, NEW.observacao, NEW.matproc, NEW.autoria); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="processojudadmauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.processojudadmauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;PROCESSOJUDADMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoprocesso, datainicial, descricaojudadm, codigoprocessojudadm, numeroproc, datainicialval, datafinalval, enderprocessojudadm, resumoprocessojudadm, ufvara, codigomunicvara, idvara, tipoalteracaoesocial, observacao, matproc, autoria) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.tipoprocesso, OLD.datainicial, OLD.descricaojudadm, OLD.codigoprocessojudadm, OLD.numeroproc, OLD.datainicialval, OLD.datafinalval, OLD.enderprocessojudadm, OLD.resumoprocessojudadm, OLD.ufvara, OLD.codigomunicvara, OLD.idvara, OLD.tipoalteracaoesocial, OLD.observacao, OLD.matproc, OLD.autoria); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;PROCESSOJUDADMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoprocesso, datainicial, descricaojudadm, codigoprocessojudadm, numeroproc, datainicialval, datafinalval, enderprocessojudadm, resumoprocessojudadm, ufvara, codigomunicvara, idvara, tipoalteracaoesocial, observacao, matproc, autoria) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.tipoprocesso, NEW.datainicial, NEW.descricaojudadm, NEW.codigoprocessojudadm, NEW.numeroproc, NEW.datainicialval, NEW.datafinalval, NEW.enderprocessojudadm, NEW.resumoprocessojudadm, NEW.ufvara, NEW.codigomunicvara, NEW.idvara, NEW.tipoalteracaoesocial, NEW.observacao, NEW.matproc, NEW.autoria); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="processojudadmbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.processojudadmbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;PROCESSOJUDADMHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMHS(SEQHISTORICO, OPERACAO, codigoempresa, tipoprocesso, datainicial, descricaojudadm, codigoprocessojudadm, numeroproc, datainicialval, datafinalval, enderprocessojudadm, resumoprocessojudadm, ufvara, codigomunicvara, idvara, tipoalteracaoesocial, observacao, matproc, autoria) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.tipoprocesso, OLD.datainicial, OLD.descricaojudadm, OLD.codigoprocessojudadm, OLD.numeroproc, OLD.datainicialval, OLD.datafinalval, OLD.enderprocessojudadm, OLD.resumoprocessojudadm, OLD.ufvara, OLD.codigomunicvara, OLD.idvara, OLD.tipoalteracaoesocial, OLD.observacao, OLD.matproc, OLD.autoria); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="processojudadmindicsuspaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.processojudadmindicsuspaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;PROCESSOJUDADMINDICSUSPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMINDICSUSPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoprocessojudadm, codigoindicsusp, decisao, datadecisao, depositomont) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoprocessojudadm, NEW.codigoindicsusp, NEW.decisao, NEW.datadecisao, NEW.depositomont); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="processojudadmindicsuspauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.processojudadmindicsuspauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;PROCESSOJUDADMINDICSUSPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMINDICSUSPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoprocessojudadm, codigoindicsusp, decisao, datadecisao, depositomont) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoprocessojudadm, OLD.codigoindicsusp, OLD.decisao, OLD.datadecisao, OLD.depositomont); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;PROCESSOJUDADMINDICSUSPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMINDICSUSPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoprocessojudadm, codigoindicsusp, decisao, datadecisao, depositomont) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoprocessojudadm, NEW.codigoindicsusp, NEW.decisao, NEW.datadecisao, NEW.depositomont); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="processojudadmindicsuspbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.processojudadmindicsuspbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;PROCESSOJUDADMINDICSUSPHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO PROCESSOJUDADMINDICSUSPHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoprocessojudadm, codigoindicsusp, decisao, datadecisao, depositomont) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoprocessojudadm, OLD.codigoindicsusp, OLD.decisao, OLD.datadecisao, OLD.depositomont); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="produtospedfis0205f" procedure_source="CREATE OR REPLACE FUNCTION public.produtospedfis0205f()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;DECLARE &#010;VALORLOG VARCHAR(120);&#010;BEGIN&#010;  IF (OLD.REFERENPRODUTO &lt;&gt; NEW.REFERENPRODUTO) THEN&#010;    SELECT VLRANTERIOR&#010;FROM SPEDFIS0205 S&#010;    WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#010;AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#010;AND NUMCAMPO = 2&#010;AND DATAALTER = CURRENT_DATE INTO VALORLOG;&#010;    IF /*(row_count = 0)*/NOT FOUND THEN&#010;INSERT INTO SPEDFIS0205 (CODIGOEMPRESA, CODIGOPRODUTO, DATAALTER, NUMCAMPO, VLRANTERIOR, DATAINI)&#010;VALUES (NEW.CODIGOEMPRESA, NEW.CODIGOPRODUTO, CURRENT_DATE, 2, OLD.REFERENPRODUTO,&#010;(SELECT MAX(DATAALTER) FROM SPEDFIS0205 WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#010;AND CODIGOPRODUTO = NEW.CODIGOPRODUTO AND NUMCAMPO = 2));&#010;    ELSE&#010;IF (VALORLOG = NEW.REFERENPRODUTO) THEN&#010;DELETE FROM SPEDFIS0205 S&#010;WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#010;AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#010;AND NUMCAMPO = 2&#010;AND DATAALTER = CURRENT_DATE;&#010;END IF;&#010;END IF;&#010;  END IF;&#010;  IF (OLD.DESCRPRODUTO &lt;&gt; NEW.DESCRPRODUTO) THEN&#010;    SELECT VLRANTERIOR&#010;FROM SPEDFIS0205 S&#010;    WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#010;AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#010;AND NUMCAMPO = 3&#010;AND DATAALTER = CURRENT_DATE INTO VALORLOG;&#010;    IF /*(row_count = 0)*/NOT FOUND THEN&#010;INSERT INTO SPEDFIS0205 (CODIGOEMPRESA, CODIGOPRODUTO, DATAALTER, NUMCAMPO, VLRANTERIOR, DATAINI)&#010;VALUES (NEW.CODIGOEMPRESA, NEW.CODIGOPRODUTO, CURRENT_DATE, 3, OLD.DESCRPRODUTO,&#010;(SELECT MAX(DATAALTER) FROM SPEDFIS0205 WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#010;AND CODIGOPRODUTO = NEW.CODIGOPRODUTO AND NUMCAMPO = 3));&#010;    ELSE&#010;IF (VALORLOG = NEW.DESCRPRODUTO) THEN&#010;DELETE FROM SPEDFIS0205 S&#010;WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#010;AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#010;AND NUMCAMPO = 3&#010;AND DATAALTER = CURRENT_DATE;&#010;END IF;&#010;END IF;&#010;  END IF;&#010;  RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="quiupublicacaobif" procedure_source="CREATE OR REPLACE FUNCTION public.quiupublicacaobif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE&#013;&#010;  i Numeric(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (new.CODIGOQUIUPUBLICACAO is null) THEN&#013;&#010;    new.CODIGOQUIUPUBLICACAO = NEXTVAL(&apos;GENQUIUPUBLICACAO&apos;);&#013;&#010;  ELSE&#013;&#010;    BEGIN&#013;&#010;      SELECT CURRVAL(&apos;GENQUIUPUBLICACAO&apos;) INTO i;&#013;&#010;    EXCEPTION WHEN OTHERS THEN&#013;&#010;      SELECT last_value INTO i FROM GENQUIUPUBLICACAO;&#013;&#010;    END;&#013;&#010;    WHILE (NEW.CODIGOQUIUPUBLICACAO &gt; i) LOOP&#013;&#010;      SELECT nextval(&apos;GENQUIUPUBLICACAO&apos;) INTO i;&#013;&#010;    END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="reciboferiasbdf" procedure_source="CREATE OR REPLACE FUNCTION public.reciboferiasbdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010; &#010;BEGIN &#010;    RETURN OLD;&#010;END&#010;$function$&#010;"/>
<ROW pro_key="rescisaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;RESCISAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, tiporescisao, codigofunccontr, codigocausa, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavisotrab, diasavinden, diasavreav, diasestabil, diasgratif, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, diasavprop, origemdado, avisopreprop13, iniciocontagem, codigopercalculo, diassaldosalario, avisoprepropferias, avosferiasind, datapagtorevisado, observacao, motivodesligamentodiretor, percpensaojud, numcertobito, numproctrab, cnpjsucessor, dataquarentena, nomesubstituto, cpfsubstituto, datanascsubstituto, emprestimogarantiafgts, indcumpparcialavisoprevio, razaosocialsucessor, quarentenaremunerada, matriculaconsignatariafgts, numerocontratoemprestimofgts, tpinscsuc, tipoalteracaoesocial, avos13prop, considerarhistsal, codigosinddissidioemp, remunaposdeslig, dtfimremun, indpdv, usamemcalc) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.complementar, NEW.tiporescisao, NEW.codigofunccontr, NEW.codigocausa, NEW.codigosaque, NEW.tipoafastsefip, NEW.tipoafastcaged, NEW.tipoafastrais, NEW.codigomotdem, NEW.dataresc, NEW.dataavprevio, NEW.datapgtoresc, NEW.diastrab, NEW.diasavisotrab, NEW.diasavinden, NEW.diasavreav, NEW.diasestabil, NEW.diasgratif, NEW.salfinal, NEW.fgtsmesant, NEW.avosferiasprop, NEW.codigofpas, NEW.codigooutemp, NEW.saldofgts, NEW.remmesant, NEW.remmesant13, NEW.valormesant, NEW.remmesantrecol, NEW.remmesant13recol, NEW.valormesantrecol, NEW.remmes, NEW.remmes13, NEW.valormes, NEW.remmesrecol, NEW.remmes13recol, NEW.valormesrecol, NEW.reminden, NEW.reminden13, NEW.valorinden, NEW.remindenrecol, NEW.reminden13recol, NEW.valorindenrecol, NEW.remmulta, NEW.valormulta, NEW.remmultarecol, NEW.valormultarecol, NEW.baseinss, NEW.deducao, NEW.salfamilia, NEW.fgtsrecol, NEW.valorinss, NEW.remunrescisao, NEW.remunsegdesempant, NEW.remunsegdesemppen, NEW.remunsegdesempult, NEW.remunult6meses, NEW.datacalcatrasogrfc, NEW.jammesant, NEW.jammes, NEW.jaminden, NEW.jammulta, NEW.datahomologresc, NEW.localhomologresc, NEW.reposicaovaga, NEW.novoempregoavprevio, NEW.dispensaavprevio, NEW.cumpriujornadaintegralsemafast, NEW.jornadatrabsabcompensemafast, NEW.avisoprevio, NEW.codigousuario, NEW.datahoralcto, NEW.diasavprop, NEW.origemdado, NEW.avisopreprop13, NEW.iniciocontagem, NEW.codigopercalculo, NEW.diassaldosalario, NEW.avisoprepropferias, NEW.avosferiasind, NEW.datapagtorevisado, NEW.observacao, NEW.motivodesligamentodiretor, NEW.percpensaojud, NEW.numcertobito, NEW.numproctrab, NEW.cnpjsucessor, NEW.dataquarentena, NEW.nomesubstituto, NEW.cpfsubstituto, NEW.datanascsubstituto, NEW.emprestimogarantiafgts, NEW.indcumpparcialavisoprevio, NEW.razaosocialsucessor, NEW.quarentenaremunerada, NEW.matriculaconsignatariafgts, NEW.numerocontratoemprestimofgts, NEW.tpinscsuc, NEW.tipoalteracaoesocial, NEW.avos13prop, NEW.considerarhistsal, NEW.codigosinddissidioemp, NEW.remunaposdeslig, NEW.dtfimremun, NEW.indpdv, NEW.usamemcalc); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;RESCISAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, tiporescisao, codigofunccontr, codigocausa, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavisotrab, diasavinden, diasavreav, diasestabil, diasgratif, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, diasavprop, origemdado, avisopreprop13, iniciocontagem, codigopercalculo, diassaldosalario, avisoprepropferias, avosferiasind, datapagtorevisado, observacao, motivodesligamentodiretor, percpensaojud, numcertobito, numproctrab, cnpjsucessor, dataquarentena, nomesubstituto, cpfsubstituto, datanascsubstituto, emprestimogarantiafgts, indcumpparcialavisoprevio, razaosocialsucessor, quarentenaremunerada, matriculaconsignatariafgts, numerocontratoemprestimofgts, tpinscsuc, tipoalteracaoesocial, avos13prop, considerarhistsal, codigosinddissidioemp, remunaposdeslig, dtfimremun, indpdv, usamemcalc) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.complementar, OLD.tiporescisao, OLD.codigofunccontr, OLD.codigocausa, OLD.codigosaque, OLD.tipoafastsefip, OLD.tipoafastcaged, OLD.tipoafastrais, OLD.codigomotdem, OLD.dataresc, OLD.dataavprevio, OLD.datapgtoresc, OLD.diastrab, OLD.diasavisotrab, OLD.diasavinden, OLD.diasavreav, OLD.diasestabil, OLD.diasgratif, OLD.salfinal, OLD.fgtsmesant, OLD.avosferiasprop, OLD.codigofpas, OLD.codigooutemp, OLD.saldofgts, OLD.remmesant, OLD.remmesant13, OLD.valormesant, OLD.remmesantrecol, OLD.remmesant13recol, OLD.valormesantrecol, OLD.remmes, OLD.remmes13, OLD.valormes, OLD.remmesrecol, OLD.remmes13recol, OLD.valormesrecol, OLD.reminden, OLD.reminden13, OLD.valorinden, OLD.remindenrecol, OLD.reminden13recol, OLD.valorindenrecol, OLD.remmulta, OLD.valormulta, OLD.remmultarecol, OLD.valormultarecol, OLD.baseinss, OLD.deducao, OLD.salfamilia, OLD.fgtsrecol, OLD.valorinss, OLD.remunrescisao, OLD.remunsegdesempant, OLD.remunsegdesemppen, OLD.remunsegdesempult, OLD.remunult6meses, OLD.datacalcatrasogrfc, OLD.jammesant, OLD.jammes, OLD.jaminden, OLD.jammulta, OLD.datahomologresc, OLD.localhomologresc, OLD.reposicaovaga, OLD.novoempregoavprevio, OLD.dispensaavprevio, OLD.cumpriujornadaintegralsemafast, OLD.jornadatrabsabcompensemafast, OLD.avisoprevio, OLD.codigousuario, OLD.datahoralcto, OLD.diasavprop, OLD.origemdado, OLD.avisopreprop13, OLD.iniciocontagem, OLD.codigopercalculo, OLD.diassaldosalario, OLD.avisoprepropferias, OLD.avosferiasind, OLD.datapagtorevisado, OLD.observacao, OLD.motivodesligamentodiretor, OLD.percpensaojud, OLD.numcertobito, OLD.numproctrab, OLD.cnpjsucessor, OLD.dataquarentena, OLD.nomesubstituto, OLD.cpfsubstituto, OLD.datanascsubstituto, OLD.emprestimogarantiafgts, OLD.indcumpparcialavisoprevio, OLD.razaosocialsucessor, OLD.quarentenaremunerada, OLD.matriculaconsignatariafgts, OLD.numerocontratoemprestimofgts, OLD.tpinscsuc, OLD.tipoalteracaoesocial, OLD.avos13prop, OLD.considerarhistsal, OLD.codigosinddissidioemp, OLD.remunaposdeslig, OLD.dtfimremun, OLD.indpdv, OLD.usamemcalc); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;RESCISAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, tiporescisao, codigofunccontr, codigocausa, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavisotrab, diasavinden, diasavreav, diasestabil, diasgratif, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, diasavprop, origemdado, avisopreprop13, iniciocontagem, codigopercalculo, diassaldosalario, avisoprepropferias, avosferiasind, datapagtorevisado, observacao, motivodesligamentodiretor, percpensaojud, numcertobito, numproctrab, cnpjsucessor, dataquarentena, nomesubstituto, cpfsubstituto, datanascsubstituto, emprestimogarantiafgts, indcumpparcialavisoprevio, razaosocialsucessor, quarentenaremunerada, matriculaconsignatariafgts, numerocontratoemprestimofgts, tpinscsuc, tipoalteracaoesocial, avos13prop, considerarhistsal, codigosinddissidioemp, remunaposdeslig, dtfimremun, indpdv, usamemcalc) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.complementar, NEW.tiporescisao, NEW.codigofunccontr, NEW.codigocausa, NEW.codigosaque, NEW.tipoafastsefip, NEW.tipoafastcaged, NEW.tipoafastrais, NEW.codigomotdem, NEW.dataresc, NEW.dataavprevio, NEW.datapgtoresc, NEW.diastrab, NEW.diasavisotrab, NEW.diasavinden, NEW.diasavreav, NEW.diasestabil, NEW.diasgratif, NEW.salfinal, NEW.fgtsmesant, NEW.avosferiasprop, NEW.codigofpas, NEW.codigooutemp, NEW.saldofgts, NEW.remmesant, NEW.remmesant13, NEW.valormesant, NEW.remmesantrecol, NEW.remmesant13recol, NEW.valormesantrecol, NEW.remmes, NEW.remmes13, NEW.valormes, NEW.remmesrecol, NEW.remmes13recol, NEW.valormesrecol, NEW.reminden, NEW.reminden13, NEW.valorinden, NEW.remindenrecol, NEW.reminden13recol, NEW.valorindenrecol, NEW.remmulta, NEW.valormulta, NEW.remmultarecol, NEW.valormultarecol, NEW.baseinss, NEW.deducao, NEW.salfamilia, NEW.fgtsrecol, NEW.valorinss, NEW.remunrescisao, NEW.remunsegdesempant, NEW.remunsegdesemppen, NEW.remunsegdesempult, NEW.remunult6meses, NEW.datacalcatrasogrfc, NEW.jammesant, NEW.jammes, NEW.jaminden, NEW.jammulta, NEW.datahomologresc, NEW.localhomologresc, NEW.reposicaovaga, NEW.novoempregoavprevio, NEW.dispensaavprevio, NEW.cumpriujornadaintegralsemafast, NEW.jornadatrabsabcompensemafast, NEW.avisoprevio, NEW.codigousuario, NEW.datahoralcto, NEW.diasavprop, NEW.origemdado, NEW.avisopreprop13, NEW.iniciocontagem, NEW.codigopercalculo, NEW.diassaldosalario, NEW.avisoprepropferias, NEW.avosferiasind, NEW.datapagtorevisado, NEW.observacao, NEW.motivodesligamentodiretor, NEW.percpensaojud, NEW.numcertobito, NEW.numproctrab, NEW.cnpjsucessor, NEW.dataquarentena, NEW.nomesubstituto, NEW.cpfsubstituto, NEW.datanascsubstituto, NEW.emprestimogarantiafgts, NEW.indcumpparcialavisoprevio, NEW.razaosocialsucessor, NEW.quarentenaremunerada, NEW.matriculaconsignatariafgts, NEW.numerocontratoemprestimofgts, NEW.tpinscsuc, NEW.tipoalteracaoesocial, NEW.avos13prop, NEW.considerarhistsal, NEW.codigosinddissidioemp, NEW.remunaposdeslig, NEW.dtfimremun, NEW.indpdv, NEW.usamemcalc); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;RESCISAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, tiporescisao, codigofunccontr, codigocausa, codigosaque, tipoafastsefip, tipoafastcaged, tipoafastrais, codigomotdem, dataresc, dataavprevio, datapgtoresc, diastrab, diasavisotrab, diasavinden, diasavreav, diasestabil, diasgratif, salfinal, fgtsmesant, avosferiasprop, codigofpas, codigooutemp, saldofgts, remmesant, remmesant13, valormesant, remmesantrecol, remmesant13recol, valormesantrecol, remmes, remmes13, valormes, remmesrecol, remmes13recol, valormesrecol, reminden, reminden13, valorinden, remindenrecol, reminden13recol, valorindenrecol, remmulta, valormulta, remmultarecol, valormultarecol, baseinss, deducao, salfamilia, fgtsrecol, valorinss, remunrescisao, remunsegdesempant, remunsegdesemppen, remunsegdesempult, remunult6meses, datacalcatrasogrfc, jammesant, jammes, jaminden, jammulta, datahomologresc, localhomologresc, reposicaovaga, novoempregoavprevio, dispensaavprevio, cumpriujornadaintegralsemafast, jornadatrabsabcompensemafast, avisoprevio, codigousuario, datahoralcto, diasavprop, origemdado, avisopreprop13, iniciocontagem, codigopercalculo, diassaldosalario, avisoprepropferias, avosferiasind, datapagtorevisado, observacao, motivodesligamentodiretor, percpensaojud, numcertobito, numproctrab, cnpjsucessor, dataquarentena, nomesubstituto, cpfsubstituto, datanascsubstituto, emprestimogarantiafgts, indcumpparcialavisoprevio, razaosocialsucessor, quarentenaremunerada, matriculaconsignatariafgts, numerocontratoemprestimofgts, tpinscsuc, tipoalteracaoesocial, avos13prop, considerarhistsal, codigosinddissidioemp, remunaposdeslig, dtfimremun, indpdv, usamemcalc) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.complementar, OLD.tiporescisao, OLD.codigofunccontr, OLD.codigocausa, OLD.codigosaque, OLD.tipoafastsefip, OLD.tipoafastcaged, OLD.tipoafastrais, OLD.codigomotdem, OLD.dataresc, OLD.dataavprevio, OLD.datapgtoresc, OLD.diastrab, OLD.diasavisotrab, OLD.diasavinden, OLD.diasavreav, OLD.diasestabil, OLD.diasgratif, OLD.salfinal, OLD.fgtsmesant, OLD.avosferiasprop, OLD.codigofpas, OLD.codigooutemp, OLD.saldofgts, OLD.remmesant, OLD.remmesant13, OLD.valormesant, OLD.remmesantrecol, OLD.remmesant13recol, OLD.valormesantrecol, OLD.remmes, OLD.remmes13, OLD.valormes, OLD.remmesrecol, OLD.remmes13recol, OLD.valormesrecol, OLD.reminden, OLD.reminden13, OLD.valorinden, OLD.remindenrecol, OLD.reminden13recol, OLD.valorindenrecol, OLD.remmulta, OLD.valormulta, OLD.remmultarecol, OLD.valormultarecol, OLD.baseinss, OLD.deducao, OLD.salfamilia, OLD.fgtsrecol, OLD.valorinss, OLD.remunrescisao, OLD.remunsegdesempant, OLD.remunsegdesemppen, OLD.remunsegdesempult, OLD.remunult6meses, OLD.datacalcatrasogrfc, OLD.jammesant, OLD.jammes, OLD.jaminden, OLD.jammulta, OLD.datahomologresc, OLD.localhomologresc, OLD.reposicaovaga, OLD.novoempregoavprevio, OLD.dispensaavprevio, OLD.cumpriujornadaintegralsemafast, OLD.jornadatrabsabcompensemafast, OLD.avisoprevio, OLD.codigousuario, OLD.datahoralcto, OLD.diasavprop, OLD.origemdado, OLD.avisopreprop13, OLD.iniciocontagem, OLD.codigopercalculo, OLD.diassaldosalario, OLD.avisoprepropferias, OLD.avosferiasind, OLD.datapagtorevisado, OLD.observacao, OLD.motivodesligamentodiretor, OLD.percpensaojud, OLD.numcertobito, OLD.numproctrab, OLD.cnpjsucessor, OLD.dataquarentena, OLD.nomesubstituto, OLD.cpfsubstituto, OLD.datanascsubstituto, OLD.emprestimogarantiafgts, OLD.indcumpparcialavisoprevio, OLD.razaosocialsucessor, OLD.quarentenaremunerada, OLD.matriculaconsignatariafgts, OLD.numerocontratoemprestimofgts, OLD.tpinscsuc, OLD.tipoalteracaoesocial, OLD.avos13prop, OLD.considerarhistsal, OLD.codigosinddissidioemp, OLD.remunaposdeslig, OLD.dtfimremun, OLD.indpdv, OLD.usamemcalc); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaoeventoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaoeventoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;RESCISAOEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOEVENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, referevento, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.complementar, NEW.codigofunccontr, NEW.codigoevento, NEW.referevento, NEW.valorevento, NEW.origemdado, NEW.baseevento); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaoeventoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaoeventoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;RESCISAOEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOEVENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, referevento, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.complementar, OLD.codigofunccontr, OLD.codigoevento, OLD.referevento, OLD.valorevento, OLD.origemdado, OLD.baseevento); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;RESCISAOEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOEVENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, referevento, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.complementar, NEW.codigofunccontr, NEW.codigoevento, NEW.referevento, NEW.valorevento, NEW.origemdado, NEW.baseevento); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaoeventobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaoeventobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;RESCISAOEVENTOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAOEVENTOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, referevento, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.complementar, OLD.codigofunccontr, OLD.codigoevento, OLD.referevento, OLD.valorevento, OLD.origemdado, OLD.baseevento); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaorateioaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaorateioaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;RESCISAORATEIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAORATEIOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, seq, codigocentrocusto, codigooutemp, referevento, codigoproftipoaula, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.complementar, NEW.codigofunccontr, NEW.codigoevento, NEW.seq, NEW.codigocentrocusto, NEW.codigooutemp, NEW.referevento, NEW.codigoproftipoaula, NEW.valorevento, NEW.origemdado, NEW.baseevento); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaorateioauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaorateioauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;RESCISAORATEIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAORATEIOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, seq, codigocentrocusto, codigooutemp, referevento, codigoproftipoaula, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.complementar, OLD.codigofunccontr, OLD.codigoevento, OLD.seq, OLD.codigocentrocusto, OLD.codigooutemp, OLD.referevento, OLD.codigoproftipoaula, OLD.valorevento, OLD.origemdado, OLD.baseevento); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;RESCISAORATEIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAORATEIOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, seq, codigocentrocusto, codigooutemp, referevento, codigoproftipoaula, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.complementar, NEW.codigofunccontr, NEW.codigoevento, NEW.seq, NEW.codigocentrocusto, NEW.codigooutemp, NEW.referevento, NEW.codigoproftipoaula, NEW.valorevento, NEW.origemdado, NEW.baseevento); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="rescisaorateiobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.rescisaorateiobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;RESCISAORATEIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO RESCISAORATEIOHS(SEQHISTORICO, OPERACAO, codigoempresa, complementar, codigofunccontr, codigoevento, seq, codigocentrocusto, codigooutemp, referevento, codigoproftipoaula, valorevento, origemdado, baseevento) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.complementar, OLD.codigofunccontr, OLD.codigoevento, OLD.seq, OLD.codigocentrocusto, OLD.codigooutemp, OLD.referevento, OLD.codigoproftipoaula, OLD.valorevento, OLD.origemdado, OLD.baseevento); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="segmentocestbif" procedure_source="CREATE OR REPLACE FUNCTION public.segmentocestbif()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i SMALLINT;&#013;&#010;BEGIN&#013;&#010;  IF (new.CODIGOSEGMENTOCEST is null) THEN&#013;&#010;    new.CODIGOSEGMENTOCEST = NEXTVAL(&apos;gen_codigosegmentocest&apos;);/**/&#013;&#010;  ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gen_codigosegmentocest&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gen_codigosegmentocest;&#013;&#010;END;&#013;&#010;WHILE (NEW.CODIGOSEGMENTOCEST &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gen_codigosegmentocest&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;  END IF;&#013;&#010;  RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="servicotercaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.servicotercaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SERVICOTERCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCHS(SEQHISTORICO, OPERACAO, codigoservico, descrservico, origemgps, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoevento) &#013;&#010;  VALUES (GEN, 1, NEW.codigoservico, NEW.descrservico, NEW.origemgps, NEW.codigoeventoesocial, NEW.incidesocialcp, NEW.incidesocialirrf, NEW.incidesocialfgts, NEW.incidesocialcontrsind, NEW.tipoevento); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="servicotercauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.servicotercauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SERVICOTERCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCHS(SEQHISTORICO, OPERACAO, codigoservico, descrservico, origemgps, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoevento) &#013;&#010;  VALUES (GEN, 2, OLD.codigoservico, OLD.descrservico, OLD.origemgps, OLD.codigoeventoesocial, OLD.incidesocialcp, OLD.incidesocialirrf, OLD.incidesocialfgts, OLD.incidesocialcontrsind, OLD.tipoevento); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SERVICOTERCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCHS(SEQHISTORICO, OPERACAO, codigoservico, descrservico, origemgps, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoevento) &#013;&#010;  VALUES (GEN, 3, NEW.codigoservico, NEW.descrservico, NEW.origemgps, NEW.codigoeventoesocial, NEW.incidesocialcp, NEW.incidesocialirrf, NEW.incidesocialfgts, NEW.incidesocialcontrsind, NEW.tipoevento); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="servicotercbdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.servicotercbdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SERVICOTERCHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCHS(SEQHISTORICO, OPERACAO, codigoservico, descrservico, origemgps, codigoeventoesocial, incidesocialcp, incidesocialirrf, incidesocialfgts, incidesocialcontrsind, tipoevento) &#013;&#010;  VALUES (GEN, 4, OLD.codigoservico, OLD.descrservico, OLD.origemgps, OLD.codigoeventoesocial, OLD.incidesocialcp, OLD.incidesocialirrf, OLD.incidesocialfgts, OLD.incidesocialcontrsind, OLD.tipoevento); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="servicotercempresaaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.servicotercempresaaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;SERVICOTERCEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoservico, datainicial, status) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigoservico, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="servicotercempresaauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.servicotercempresaauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;SERVICOTERCEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoservico, datainicial, status) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigoservico, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;SERVICOTERCEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoservico, datainicial, status) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigoservico, NEW.datainicial, NEW.status); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="servicotercempresabdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.servicotercempresabdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;SERVICOTERCEMPRESAHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SERVICOTERCEMPRESAHS(SEQHISTORICO, OPERACAO, codigoempresa, codigoservico, datainicial, status) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigoservico, OLD.datainicial, OLD.status); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="sindconvencaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.sindconvencaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDCONVENCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDCONVENCAOHS(SEQHISTORICO, OPERACAO, codigosind, datainicial, mesadto13, percadto, permcompl, admanoconsidate12, media13somenteano, pagamediaadto13, adto13ferias, diasavo13sal, diasavo13mesfevereiro, desconsdia31inden13, tipoauxiliocreche, tipocalcauxiliocreche, valorcalculoauxcre, valorminimoauxcre, valormaximoauxcre, meseshomologresc, tipoassid, limiteassid, codigoassiduidade, percassid, mesdatabase, mesesferiasproporc, mesesmediahoraext, diasindenizacaomesantdissidio, maiormediahoraext, anospremio, mesesmediavalvar, divmediahoraext, anuidadetemposervico, descmenorvalmedhoraext, maioresmediavalvar, somarreavferias13, avaliarmaiorvalor, rescisaofimantecipado, mediarescisao, codigoanuidade, divisormediavalvar, codigoavisoprevio, percadicnot, descmenorvalmedvalvar, tipoquebracaixa, valorquebra, iniciohorarionot, mesesindenhoraext, tetominimo, codigomoeda, tetomaximo, fimhorarionot, utilmedmedferias, continuahorarionoturno, tipomediavalvar, contrperaquis, possuicorrecao, tipomediahoraext, pgtoferiasmensal, perc1tercferias, tipomediaprovisao, pgtoferiashorista, desconsdia31indenferias, diasavoferias, divmediaha, divmediahavalor, enderconvenc, premiotemposervico, integabonoferias, integirrfferias, maiormediaha, maiormediahavalor, mesesmediaha, diaconversao, diacontrexp, conttempavisprevnoavisprev, diaprorrogcontrexp, tipoadicnot, diasavisotrab, mesesmediahavalor, limiteiniciojornadahornot, assiduidadetipodescon, rescisaoacordo, dataefeito, appacordo, pagamento13salhorista, divmedia13integral) &#013;&#010;  VALUES (GEN, 1, NEW.codigosind, NEW.datainicial, NEW.mesadto13, NEW.percadto, NEW.permcompl, NEW.admanoconsidate12, NEW.media13somenteano, NEW.pagamediaadto13, NEW.adto13ferias, NEW.diasavo13sal, NEW.diasavo13mesfevereiro, NEW.desconsdia31inden13, NEW.tipoauxiliocreche, NEW.tipocalcauxiliocreche, NEW.valorcalculoauxcre, NEW.valorminimoauxcre, NEW.valormaximoauxcre, NEW.meseshomologresc, NEW.tipoassid, NEW.limiteassid, NEW.codigoassiduidade, NEW.percassid, NEW.mesdatabase, NEW.mesesferiasproporc, NEW.mesesmediahoraext, NEW.diasindenizacaomesantdissidio, NEW.maiormediahoraext, NEW.anospremio, NEW.mesesmediavalvar, NEW.divmediahoraext, NEW.anuidadetemposervico, NEW.descmenorvalmedhoraext, NEW.maioresmediavalvar, NEW.somarreavferias13, NEW.avaliarmaiorvalor, NEW.rescisaofimantecipado, NEW.mediarescisao, NEW.codigoanuidade, NEW.divisormediavalvar, NEW.codigoavisoprevio, NEW.percadicnot, NEW.descmenorvalmedvalvar, NEW.tipoquebracaixa, NEW.valorquebra, NEW.iniciohorarionot, NEW.mesesindenhoraext, NEW.tetominimo, NEW.codigomoeda, NEW.tetomaximo, NEW.fimhorarionot, NEW.utilmedmedferias, NEW.continuahorarionoturno, NEW.tipomediavalvar, NEW.contrperaquis, NEW.possuicorrecao, NEW.tipomediahoraext, NEW.pgtoferiasmensal, NEW.perc1tercferias, NEW.tipomediaprovisao, NEW.pgtoferiashorista, NEW.desconsdia31indenferias, NEW.diasavoferias, NEW.divmediaha, NEW.divmediahavalor, NEW.enderconvenc, NEW.premiotemposervico, NEW.integabonoferias, NEW.integirrfferias, NEW.maiormediaha, NEW.maiormediahavalor, NEW.mesesmediaha, NEW.diaconversao, NEW.diacontrexp, NEW.conttempavisprevnoavisprev, NEW.diaprorrogcontrexp, NEW.tipoadicnot, NEW.diasavisotrab, NEW.mesesmediahavalor, NEW.limiteiniciojornadahornot, NEW.assiduidadetipodescon, NEW.rescisaoacordo, NEW.dataefeito, NEW.appacordo, NEW.pagamento13salhorista, NEW.divmedia13integral); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="sindconvencaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.sindconvencaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDCONVENCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDCONVENCAOHS(SEQHISTORICO, OPERACAO, codigosind, datainicial, mesadto13, percadto, permcompl, admanoconsidate12, media13somenteano, pagamediaadto13, adto13ferias, diasavo13sal, diasavo13mesfevereiro, desconsdia31inden13, tipoauxiliocreche, tipocalcauxiliocreche, valorcalculoauxcre, valorminimoauxcre, valormaximoauxcre, meseshomologresc, tipoassid, limiteassid, codigoassiduidade, percassid, mesdatabase, mesesferiasproporc, mesesmediahoraext, diasindenizacaomesantdissidio, maiormediahoraext, anospremio, mesesmediavalvar, divmediahoraext, anuidadetemposervico, descmenorvalmedhoraext, maioresmediavalvar, somarreavferias13, avaliarmaiorvalor, rescisaofimantecipado, mediarescisao, codigoanuidade, divisormediavalvar, codigoavisoprevio, percadicnot, descmenorvalmedvalvar, tipoquebracaixa, valorquebra, iniciohorarionot, mesesindenhoraext, tetominimo, codigomoeda, tetomaximo, fimhorarionot, utilmedmedferias, continuahorarionoturno, tipomediavalvar, contrperaquis, possuicorrecao, tipomediahoraext, pgtoferiasmensal, perc1tercferias, tipomediaprovisao, pgtoferiashorista, desconsdia31indenferias, diasavoferias, divmediaha, divmediahavalor, enderconvenc, premiotemposervico, integabonoferias, integirrfferias, maiormediaha, maiormediahavalor, mesesmediaha, diaconversao, diacontrexp, conttempavisprevnoavisprev, diaprorrogcontrexp, tipoadicnot, diasavisotrab, mesesmediahavalor, limiteiniciojornadahornot, assiduidadetipodescon, rescisaoacordo, dataefeito, appacordo, pagamento13salhorista, divmedia13integral) &#013;&#010;  VALUES (GEN, 2, OLD.codigosind, OLD.datainicial, OLD.mesadto13, OLD.percadto, OLD.permcompl, OLD.admanoconsidate12, OLD.media13somenteano, OLD.pagamediaadto13, OLD.adto13ferias, OLD.diasavo13sal, OLD.diasavo13mesfevereiro, OLD.desconsdia31inden13, OLD.tipoauxiliocreche, OLD.tipocalcauxiliocreche, OLD.valorcalculoauxcre, OLD.valorminimoauxcre, OLD.valormaximoauxcre, OLD.meseshomologresc, OLD.tipoassid, OLD.limiteassid, OLD.codigoassiduidade, OLD.percassid, OLD.mesdatabase, OLD.mesesferiasproporc, OLD.mesesmediahoraext, OLD.diasindenizacaomesantdissidio, OLD.maiormediahoraext, OLD.anospremio, OLD.mesesmediavalvar, OLD.divmediahoraext, OLD.anuidadetemposervico, OLD.descmenorvalmedhoraext, OLD.maioresmediavalvar, OLD.somarreavferias13, OLD.avaliarmaiorvalor, OLD.rescisaofimantecipado, OLD.mediarescisao, OLD.codigoanuidade, OLD.divisormediavalvar, OLD.codigoavisoprevio, OLD.percadicnot, OLD.descmenorvalmedvalvar, OLD.tipoquebracaixa, OLD.valorquebra, OLD.iniciohorarionot, OLD.mesesindenhoraext, OLD.tetominimo, OLD.codigomoeda, OLD.tetomaximo, OLD.fimhorarionot, OLD.utilmedmedferias, OLD.continuahorarionoturno, OLD.tipomediavalvar, OLD.contrperaquis, OLD.possuicorrecao, OLD.tipomediahoraext, OLD.pgtoferiasmensal, OLD.perc1tercferias, OLD.tipomediaprovisao, OLD.pgtoferiashorista, OLD.desconsdia31indenferias, OLD.diasavoferias, OLD.divmediaha, OLD.divmediahavalor, OLD.enderconvenc, OLD.premiotemposervico, OLD.integabonoferias, OLD.integirrfferias, OLD.maiormediaha, OLD.maiormediahavalor, OLD.mesesmediaha, OLD.diaconversao, OLD.diacontrexp, OLD.conttempavisprevnoavisprev, OLD.diaprorrogcontrexp, OLD.tipoadicnot, OLD.diasavisotrab, OLD.mesesmediahavalor, OLD.limiteiniciojornadahornot, OLD.assiduidadetipodescon, OLD.rescisaoacordo, OLD.dataefeito, OLD.appacordo, OLD.pagamento13salhorista, OLD.divmedia13integral); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDCONVENCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDCONVENCAOHS(SEQHISTORICO, OPERACAO, codigosind, datainicial, mesadto13, percadto, permcompl, admanoconsidate12, media13somenteano, pagamediaadto13, adto13ferias, diasavo13sal, diasavo13mesfevereiro, desconsdia31inden13, tipoauxiliocreche, tipocalcauxiliocreche, valorcalculoauxcre, valorminimoauxcre, valormaximoauxcre, meseshomologresc, tipoassid, limiteassid, codigoassiduidade, percassid, mesdatabase, mesesferiasproporc, mesesmediahoraext, diasindenizacaomesantdissidio, maiormediahoraext, anospremio, mesesmediavalvar, divmediahoraext, anuidadetemposervico, descmenorvalmedhoraext, maioresmediavalvar, somarreavferias13, avaliarmaiorvalor, rescisaofimantecipado, mediarescisao, codigoanuidade, divisormediavalvar, codigoavisoprevio, percadicnot, descmenorvalmedvalvar, tipoquebracaixa, valorquebra, iniciohorarionot, mesesindenhoraext, tetominimo, codigomoeda, tetomaximo, fimhorarionot, utilmedmedferias, continuahorarionoturno, tipomediavalvar, contrperaquis, possuicorrecao, tipomediahoraext, pgtoferiasmensal, perc1tercferias, tipomediaprovisao, pgtoferiashorista, desconsdia31indenferias, diasavoferias, divmediaha, divmediahavalor, enderconvenc, premiotemposervico, integabonoferias, integirrfferias, maiormediaha, maiormediahavalor, mesesmediaha, diaconversao, diacontrexp, conttempavisprevnoavisprev, diaprorrogcontrexp, tipoadicnot, diasavisotrab, mesesmediahavalor, limiteiniciojornadahornot, assiduidadetipodescon, rescisaoacordo, dataefeito, appacordo, pagamento13salhorista, divmedia13integral) &#013;&#010;  VALUES (GEN, 3, NEW.codigosind, NEW.datainicial, NEW.mesadto13, NEW.percadto, NEW.permcompl, NEW.admanoconsidate12, NEW.media13somenteano, NEW.pagamediaadto13, NEW.adto13ferias, NEW.diasavo13sal, NEW.diasavo13mesfevereiro, NEW.desconsdia31inden13, NEW.tipoauxiliocreche, NEW.tipocalcauxiliocreche, NEW.valorcalculoauxcre, NEW.valorminimoauxcre, NEW.valormaximoauxcre, NEW.meseshomologresc, NEW.tipoassid, NEW.limiteassid, NEW.codigoassiduidade, NEW.percassid, NEW.mesdatabase, NEW.mesesferiasproporc, NEW.mesesmediahoraext, NEW.diasindenizacaomesantdissidio, NEW.maiormediahoraext, NEW.anospremio, NEW.mesesmediavalvar, NEW.divmediahoraext, NEW.anuidadetemposervico, NEW.descmenorvalmedhoraext, NEW.maioresmediavalvar, NEW.somarreavferias13, NEW.avaliarmaiorvalor, NEW.rescisaofimantecipado, NEW.mediarescisao, NEW.codigoanuidade, NEW.divisormediavalvar, NEW.codigoavisoprevio, NEW.percadicnot, NEW.descmenorvalmedvalvar, NEW.tipoquebracaixa, NEW.valorquebra, NEW.iniciohorarionot, NEW.mesesindenhoraext, NEW.tetominimo, NEW.codigomoeda, NEW.tetomaximo, NEW.fimhorarionot, NEW.utilmedmedferias, NEW.continuahorarionoturno, NEW.tipomediavalvar, NEW.contrperaquis, NEW.possuicorrecao, NEW.tipomediahoraext, NEW.pgtoferiasmensal, NEW.perc1tercferias, NEW.tipomediaprovisao, NEW.pgtoferiashorista, NEW.desconsdia31indenferias, NEW.diasavoferias, NEW.divmediaha, NEW.divmediahavalor, NEW.enderconvenc, NEW.premiotemposervico, NEW.integabonoferias, NEW.integirrfferias, NEW.maiormediaha, NEW.maiormediahavalor, NEW.mesesmediaha, NEW.diaconversao, NEW.diacontrexp, NEW.conttempavisprevnoavisprev, NEW.diaprorrogcontrexp, NEW.tipoadicnot, NEW.diasavisotrab, NEW.mesesmediahavalor, NEW.limiteiniciojornadahornot, NEW.assiduidadetipodescon, NEW.rescisaoacordo, NEW.dataefeito, NEW.appacordo, NEW.pagamento13salhorista, NEW.divmedia13integral); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="sindconvencaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.sindconvencaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDCONVENCAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDCONVENCAOHS(SEQHISTORICO, OPERACAO, codigosind, datainicial, mesadto13, percadto, permcompl, admanoconsidate12, media13somenteano, pagamediaadto13, adto13ferias, diasavo13sal, diasavo13mesfevereiro, desconsdia31inden13, tipoauxiliocreche, tipocalcauxiliocreche, valorcalculoauxcre, valorminimoauxcre, valormaximoauxcre, meseshomologresc, tipoassid, limiteassid, codigoassiduidade, percassid, mesdatabase, mesesferiasproporc, mesesmediahoraext, diasindenizacaomesantdissidio, maiormediahoraext, anospremio, mesesmediavalvar, divmediahoraext, anuidadetemposervico, descmenorvalmedhoraext, maioresmediavalvar, somarreavferias13, avaliarmaiorvalor, rescisaofimantecipado, mediarescisao, codigoanuidade, divisormediavalvar, codigoavisoprevio, percadicnot, descmenorvalmedvalvar, tipoquebracaixa, valorquebra, iniciohorarionot, mesesindenhoraext, tetominimo, codigomoeda, tetomaximo, fimhorarionot, utilmedmedferias, continuahorarionoturno, tipomediavalvar, contrperaquis, possuicorrecao, tipomediahoraext, pgtoferiasmensal, perc1tercferias, tipomediaprovisao, pgtoferiashorista, desconsdia31indenferias, diasavoferias, divmediaha, divmediahavalor, enderconvenc, premiotemposervico, integabonoferias, integirrfferias, maiormediaha, maiormediahavalor, mesesmediaha, diaconversao, diacontrexp, conttempavisprevnoavisprev, diaprorrogcontrexp, tipoadicnot, diasavisotrab, mesesmediahavalor, limiteiniciojornadahornot, assiduidadetipodescon, rescisaoacordo, dataefeito, appacordo, pagamento13salhorista, divmedia13integral) &#013;&#010;  VALUES (GEN, 4, OLD.codigosind, OLD.datainicial, OLD.mesadto13, OLD.percadto, OLD.permcompl, OLD.admanoconsidate12, OLD.media13somenteano, OLD.pagamediaadto13, OLD.adto13ferias, OLD.diasavo13sal, OLD.diasavo13mesfevereiro, OLD.desconsdia31inden13, OLD.tipoauxiliocreche, OLD.tipocalcauxiliocreche, OLD.valorcalculoauxcre, OLD.valorminimoauxcre, OLD.valormaximoauxcre, OLD.meseshomologresc, OLD.tipoassid, OLD.limiteassid, OLD.codigoassiduidade, OLD.percassid, OLD.mesdatabase, OLD.mesesferiasproporc, OLD.mesesmediahoraext, OLD.diasindenizacaomesantdissidio, OLD.maiormediahoraext, OLD.anospremio, OLD.mesesmediavalvar, OLD.divmediahoraext, OLD.anuidadetemposervico, OLD.descmenorvalmedhoraext, OLD.maioresmediavalvar, OLD.somarreavferias13, OLD.avaliarmaiorvalor, OLD.rescisaofimantecipado, OLD.mediarescisao, OLD.codigoanuidade, OLD.divisormediavalvar, OLD.codigoavisoprevio, OLD.percadicnot, OLD.descmenorvalmedvalvar, OLD.tipoquebracaixa, OLD.valorquebra, OLD.iniciohorarionot, OLD.mesesindenhoraext, OLD.tetominimo, OLD.codigomoeda, OLD.tetomaximo, OLD.fimhorarionot, OLD.utilmedmedferias, OLD.continuahorarionoturno, OLD.tipomediavalvar, OLD.contrperaquis, OLD.possuicorrecao, OLD.tipomediahoraext, OLD.pgtoferiasmensal, OLD.perc1tercferias, OLD.tipomediaprovisao, OLD.pgtoferiashorista, OLD.desconsdia31indenferias, OLD.diasavoferias, OLD.divmediaha, OLD.divmediahavalor, OLD.enderconvenc, OLD.premiotemposervico, OLD.integabonoferias, OLD.integirrfferias, OLD.maiormediaha, OLD.maiormediahavalor, OLD.mesesmediaha, OLD.diaconversao, OLD.diacontrexp, OLD.conttempavisprevnoavisprev, OLD.diaprorrogcontrexp, OLD.tipoadicnot, OLD.diasavisotrab, OLD.mesesmediahavalor, OLD.limiteiniciojornadahornot, OLD.assiduidadetipodescon, OLD.rescisaoacordo, OLD.dataefeito, OLD.appacordo, OLD.pagamento13salhorista, OLD.divmedia13integral); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="sindicatoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.sindicatoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDICATOHS(SEQHISTORICO, OPERACAO, codigosind, nomesind, datainicial, siglasind, codigoentid, endersind, numeroender, complender, bairrosind, siglaestado, codigomunic, cepsind, caixapostal, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, patronal, codigotipolograd, inscrfederal, tipoentid, codigobanco, numeroagencia, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 1, NEW.codigosind, NEW.nomesind, NEW.datainicial, NEW.siglasind, NEW.codigoentid, NEW.endersind, NEW.numeroender, NEW.complender, NEW.bairrosind, NEW.siglaestado, NEW.codigomunic, NEW.cepsind, NEW.caixapostal, NEW.dddfone, NEW.numerofone, NEW.dddfax, NEW.numerofax, NEW.endereletr, NEW.paginainter, NEW.patronal, NEW.codigotipolograd, NEW.inscrfederal, NEW.tipoentid, NEW.codigobanco, NEW.numeroagencia, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="sindicatoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.sindicatoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDICATOHS(SEQHISTORICO, OPERACAO, codigosind, nomesind, datainicial, siglasind, codigoentid, endersind, numeroender, complender, bairrosind, siglaestado, codigomunic, cepsind, caixapostal, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, patronal, codigotipolograd, inscrfederal, tipoentid, codigobanco, numeroagencia, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 2, OLD.codigosind, OLD.nomesind, OLD.datainicial, OLD.siglasind, OLD.codigoentid, OLD.endersind, OLD.numeroender, OLD.complender, OLD.bairrosind, OLD.siglaestado, OLD.codigomunic, OLD.cepsind, OLD.caixapostal, OLD.dddfone, OLD.numerofone, OLD.dddfax, OLD.numerofax, OLD.endereletr, OLD.paginainter, OLD.patronal, OLD.codigotipolograd, OLD.inscrfederal, OLD.tipoentid, OLD.codigobanco, OLD.numeroagencia, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDICATOHS(SEQHISTORICO, OPERACAO, codigosind, nomesind, datainicial, siglasind, codigoentid, endersind, numeroender, complender, bairrosind, siglaestado, codigomunic, cepsind, caixapostal, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, patronal, codigotipolograd, inscrfederal, tipoentid, codigobanco, numeroagencia, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 3, NEW.codigosind, NEW.nomesind, NEW.datainicial, NEW.siglasind, NEW.codigoentid, NEW.endersind, NEW.numeroender, NEW.complender, NEW.bairrosind, NEW.siglaestado, NEW.codigomunic, NEW.cepsind, NEW.caixapostal, NEW.dddfone, NEW.numerofone, NEW.dddfax, NEW.numerofax, NEW.endereletr, NEW.paginainter, NEW.patronal, NEW.codigotipolograd, NEW.inscrfederal, NEW.tipoentid, NEW.codigobanco, NEW.numeroagencia, NEW.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="sindicatobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.sindicatobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SINDICATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SINDICATOHS(SEQHISTORICO, OPERACAO, codigosind, nomesind, datainicial, siglasind, codigoentid, endersind, numeroender, complender, bairrosind, siglaestado, codigomunic, cepsind, caixapostal, dddfone, numerofone, dddfax, numerofax, endereletr, paginainter, patronal, codigotipolograd, inscrfederal, tipoentid, codigobanco, numeroagencia, tipoalteracaoesocial) &#013;&#010;  VALUES (GEN, 4, OLD.codigosind, OLD.nomesind, OLD.datainicial, OLD.siglasind, OLD.codigoentid, OLD.endersind, OLD.numeroender, OLD.complender, OLD.bairrosind, OLD.siglaestado, OLD.codigomunic, OLD.cepsind, OLD.caixapostal, OLD.dddfone, OLD.numerofone, OLD.dddfax, OLD.numerofax, OLD.endereletr, OLD.paginainter, OLD.patronal, OLD.codigotipolograd, OLD.inscrfederal, OLD.tipoentid, OLD.codigobanco, OLD.numeroagencia, OLD.tipoalteracaoesocial); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="situacaoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.situacaoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SITUACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SITUACAOHS(SEQHISTORICO, OPERACAO, codigosit, descrsit, tiposit, tipoafastsefip, afastamentoesocial, tiporetornosefip, tipoafasthomolognet, tiporetornohomolognet, perdeferias, horadiautil, temposervico, diminuimesestrabsegdesemp, avosup15dias13, horasmensal, horashorista, diminuibeneficio, temporais, diminuivaletransp, diminuirefeicao, pagaadtosal, geraestabil, prorrogacontratoexp, consideradsrafast, considdiassaldosal, tipoafastrais, temposervicodiasavisoprevio, consideraavo13media) &#013;&#010;  VALUES (GEN, 1, NEW.codigosit, NEW.descrsit, NEW.tiposit, NEW.tipoafastsefip, NEW.afastamentoesocial, NEW.tiporetornosefip, NEW.tipoafasthomolognet, NEW.tiporetornohomolognet, NEW.perdeferias, NEW.horadiautil, NEW.temposervico, NEW.diminuimesestrabsegdesemp, NEW.avosup15dias13, NEW.horasmensal, NEW.horashorista, NEW.diminuibeneficio, NEW.temporais, NEW.diminuivaletransp, NEW.diminuirefeicao, NEW.pagaadtosal, NEW.geraestabil, NEW.prorrogacontratoexp, NEW.consideradsrafast, NEW.considdiassaldosal, NEW.tipoafastrais, NEW.temposervicodiasavisoprevio, NEW.consideraavo13media); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="situacaoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.situacaoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SITUACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SITUACAOHS(SEQHISTORICO, OPERACAO, codigosit, descrsit, tiposit, tipoafastsefip, afastamentoesocial, tiporetornosefip, tipoafasthomolognet, tiporetornohomolognet, perdeferias, horadiautil, temposervico, diminuimesestrabsegdesemp, avosup15dias13, horasmensal, horashorista, diminuibeneficio, temporais, diminuivaletransp, diminuirefeicao, pagaadtosal, geraestabil, prorrogacontratoexp, consideradsrafast, considdiassaldosal, tipoafastrais, temposervicodiasavisoprevio, consideraavo13media) &#013;&#010;  VALUES (GEN, 2, OLD.codigosit, OLD.descrsit, OLD.tiposit, OLD.tipoafastsefip, OLD.afastamentoesocial, OLD.tiporetornosefip, OLD.tipoafasthomolognet, OLD.tiporetornohomolognet, OLD.perdeferias, OLD.horadiautil, OLD.temposervico, OLD.diminuimesestrabsegdesemp, OLD.avosup15dias13, OLD.horasmensal, OLD.horashorista, OLD.diminuibeneficio, OLD.temporais, OLD.diminuivaletransp, OLD.diminuirefeicao, OLD.pagaadtosal, OLD.geraestabil, OLD.prorrogacontratoexp, OLD.consideradsrafast, OLD.considdiassaldosal, OLD.tipoafastrais, OLD.temposervicodiasavisoprevio, OLD.consideraavo13media); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SITUACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SITUACAOHS(SEQHISTORICO, OPERACAO, codigosit, descrsit, tiposit, tipoafastsefip, afastamentoesocial, tiporetornosefip, tipoafasthomolognet, tiporetornohomolognet, perdeferias, horadiautil, temposervico, diminuimesestrabsegdesemp, avosup15dias13, horasmensal, horashorista, diminuibeneficio, temporais, diminuivaletransp, diminuirefeicao, pagaadtosal, geraestabil, prorrogacontratoexp, consideradsrafast, considdiassaldosal, tipoafastrais, temposervicodiasavisoprevio, consideraavo13media) &#013;&#010;  VALUES (GEN, 3, NEW.codigosit, NEW.descrsit, NEW.tiposit, NEW.tipoafastsefip, NEW.afastamentoesocial, NEW.tiporetornosefip, NEW.tipoafasthomolognet, NEW.tiporetornohomolognet, NEW.perdeferias, NEW.horadiautil, NEW.temposervico, NEW.diminuimesestrabsegdesemp, NEW.avosup15dias13, NEW.horasmensal, NEW.horashorista, NEW.diminuibeneficio, NEW.temporais, NEW.diminuivaletransp, NEW.diminuirefeicao, NEW.pagaadtosal, NEW.geraestabil, NEW.prorrogacontratoexp, NEW.consideradsrafast, NEW.considdiassaldosal, NEW.tipoafastrais, NEW.temposervicodiasavisoprevio, NEW.consideraavo13media); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="situacaobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.situacaobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;SITUACAOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SITUACAOHS(SEQHISTORICO, OPERACAO, codigosit, descrsit, tiposit, tipoafastsefip, afastamentoesocial, tiporetornosefip, tipoafasthomolognet, tiporetornohomolognet, perdeferias, horadiautil, temposervico, diminuimesestrabsegdesemp, avosup15dias13, horasmensal, horashorista, diminuibeneficio, temporais, diminuivaletransp, diminuirefeicao, pagaadtosal, geraestabil, prorrogacontratoexp, consideradsrafast, considdiassaldosal, tipoafastrais, temposervicodiasavisoprevio, consideraavo13media) &#013;&#010;  VALUES (GEN, 4, OLD.codigosit, OLD.descrsit, OLD.tiposit, OLD.tipoafastsefip, OLD.afastamentoesocial, OLD.tiporetornosefip, OLD.tipoafasthomolognet, OLD.tiporetornohomolognet, OLD.perdeferias, OLD.horadiautil, OLD.temposervico, OLD.diminuimesestrabsegdesemp, OLD.avosup15dias13, OLD.horasmensal, OLD.horashorista, OLD.diminuibeneficio, OLD.temporais, OLD.diminuivaletransp, OLD.diminuirefeicao, OLD.pagaadtosal, OLD.geraestabil, OLD.prorrogacontratoexp, OLD.consideradsrafast, OLD.considdiassaldosal, OLD.tipoafastrais, OLD.temposervicodiasavisoprevio, OLD.consideraavo13media); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="socioaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.socioaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;SOCIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SOCIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigosocio, datainicial, nomesocio, tipoinscr, codigotipolograd, inscrfederal, enderecosocio, numendersocio, complendersocio, bairroendersocio, siglaestado, codigomunic, cependersocio, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, email, resplegal, perfiltareffa, tiposocio, qualificacao, descrcargo, valornominalcotas, percentcotas, quantcotas, participaassis, ordemassis, declarafisicaescrit, qualificacaosocio, socioostensivo, datainiciosocio, datafimsocio, numeroinscrinss, codigoorgaoemissorrg, pissocio, numerorg, siglaestadorg, datarg, tituloeleitornumero, tituloeleitorzona, tituloeleitorsecao, datanasc, siglaestadonasc, codigomunicnasc, nacionalidade, grauinstr, formacao, estadocivil, regimecasamento, maiormenoridade, nomerepreslegal, cpfrespreslegal, qualifrespreslegal, nomemae, inscrfederalmae, datanascmae, nomepai, inscrfederalpai, statussinczen, datanascpai, tipoalteracaoesocial, idsocioqn, statussinczenii) &#013;&#010;  VALUES (GEN, 1, NEW.codigoempresa, NEW.codigosocio, NEW.datainicial, NEW.nomesocio, NEW.tipoinscr, NEW.codigotipolograd, NEW.inscrfederal, NEW.enderecosocio, NEW.numendersocio, NEW.complendersocio, NEW.bairroendersocio, NEW.siglaestado, NEW.codigomunic, NEW.cependersocio, NEW.dddfone, NEW.numerofone, NEW.ramal, NEW.dddfax, NEW.dddcelular, NEW.numerocelular, NEW.numerofax, NEW.email, NEW.resplegal, NEW.perfiltareffa, NEW.tiposocio, NEW.qualificacao, NEW.descrcargo, NEW.valornominalcotas, NEW.percentcotas, NEW.quantcotas, NEW.participaassis, NEW.ordemassis, NEW.declarafisicaescrit, NEW.qualificacaosocio, NEW.socioostensivo, NEW.datainiciosocio, NEW.datafimsocio, NEW.numeroinscrinss, NEW.codigoorgaoemissorrg, NEW.pissocio, NEW.numerorg, NEW.siglaestadorg, NEW.datarg, NEW.tituloeleitornumero, NEW.tituloeleitorzona, NEW.tituloeleitorsecao, NEW.datanasc, NEW.siglaestadonasc, NEW.codigomunicnasc, NEW.nacionalidade, NEW.grauinstr, NEW.formacao, NEW.estadocivil, NEW.regimecasamento, NEW.maiormenoridade, NEW.nomerepreslegal, NEW.cpfrespreslegal, NEW.qualifrespreslegal, NEW.nomemae, NEW.inscrfederalmae, NEW.datanascmae, NEW.nomepai, NEW.inscrfederalpai, NEW.statussinczen, NEW.datanascpai, NEW.tipoalteracaoesocial, NEW.idsocioqn, NEW.statussinczenii); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="socioauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.socioauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;SOCIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SOCIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigosocio, datainicial, nomesocio, tipoinscr, codigotipolograd, inscrfederal, enderecosocio, numendersocio, complendersocio, bairroendersocio, siglaestado, codigomunic, cependersocio, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, email, resplegal, perfiltareffa, tiposocio, qualificacao, descrcargo, valornominalcotas, percentcotas, quantcotas, participaassis, ordemassis, declarafisicaescrit, qualificacaosocio, socioostensivo, datainiciosocio, datafimsocio, numeroinscrinss, codigoorgaoemissorrg, pissocio, numerorg, siglaestadorg, datarg, tituloeleitornumero, tituloeleitorzona, tituloeleitorsecao, datanasc, siglaestadonasc, codigomunicnasc, nacionalidade, grauinstr, formacao, estadocivil, regimecasamento, maiormenoridade, nomerepreslegal, cpfrespreslegal, qualifrespreslegal, nomemae, inscrfederalmae, datanascmae, nomepai, inscrfederalpai, statussinczen, datanascpai, tipoalteracaoesocial, idsocioqn, statussinczenii) &#013;&#010;  VALUES (GEN, 2, OLD.codigoempresa, OLD.codigosocio, OLD.datainicial, OLD.nomesocio, OLD.tipoinscr, OLD.codigotipolograd, OLD.inscrfederal, OLD.enderecosocio, OLD.numendersocio, OLD.complendersocio, OLD.bairroendersocio, OLD.siglaestado, OLD.codigomunic, OLD.cependersocio, OLD.dddfone, OLD.numerofone, OLD.ramal, OLD.dddfax, OLD.dddcelular, OLD.numerocelular, OLD.numerofax, OLD.email, OLD.resplegal, OLD.perfiltareffa, OLD.tiposocio, OLD.qualificacao, OLD.descrcargo, OLD.valornominalcotas, OLD.percentcotas, OLD.quantcotas, OLD.participaassis, OLD.ordemassis, OLD.declarafisicaescrit, OLD.qualificacaosocio, OLD.socioostensivo, OLD.datainiciosocio, OLD.datafimsocio, OLD.numeroinscrinss, OLD.codigoorgaoemissorrg, OLD.pissocio, OLD.numerorg, OLD.siglaestadorg, OLD.datarg, OLD.tituloeleitornumero, OLD.tituloeleitorzona, OLD.tituloeleitorsecao, OLD.datanasc, OLD.siglaestadonasc, OLD.codigomunicnasc, OLD.nacionalidade, OLD.grauinstr, OLD.formacao, OLD.estadocivil, OLD.regimecasamento, OLD.maiormenoridade, OLD.nomerepreslegal, OLD.cpfrespreslegal, OLD.qualifrespreslegal, OLD.nomemae, OLD.inscrfederalmae, OLD.datanascmae, OLD.nomepai, OLD.inscrfederalpai, OLD.statussinczen, OLD.datanascpai, OLD.tipoalteracaoesocial, OLD.idsocioqn, OLD.statussinczenii); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, NEW.CODIGOEMPRESA, &apos;SOCIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SOCIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigosocio, datainicial, nomesocio, tipoinscr, codigotipolograd, inscrfederal, enderecosocio, numendersocio, complendersocio, bairroendersocio, siglaestado, codigomunic, cependersocio, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, email, resplegal, perfiltareffa, tiposocio, qualificacao, descrcargo, valornominalcotas, percentcotas, quantcotas, participaassis, ordemassis, declarafisicaescrit, qualificacaosocio, socioostensivo, datainiciosocio, datafimsocio, numeroinscrinss, codigoorgaoemissorrg, pissocio, numerorg, siglaestadorg, datarg, tituloeleitornumero, tituloeleitorzona, tituloeleitorsecao, datanasc, siglaestadonasc, codigomunicnasc, nacionalidade, grauinstr, formacao, estadocivil, regimecasamento, maiormenoridade, nomerepreslegal, cpfrespreslegal, qualifrespreslegal, nomemae, inscrfederalmae, datanascmae, nomepai, inscrfederalpai, statussinczen, datanascpai, tipoalteracaoesocial, idsocioqn, statussinczenii) &#013;&#010;  VALUES (GEN, 3, NEW.codigoempresa, NEW.codigosocio, NEW.datainicial, NEW.nomesocio, NEW.tipoinscr, NEW.codigotipolograd, NEW.inscrfederal, NEW.enderecosocio, NEW.numendersocio, NEW.complendersocio, NEW.bairroendersocio, NEW.siglaestado, NEW.codigomunic, NEW.cependersocio, NEW.dddfone, NEW.numerofone, NEW.ramal, NEW.dddfax, NEW.dddcelular, NEW.numerocelular, NEW.numerofax, NEW.email, NEW.resplegal, NEW.perfiltareffa, NEW.tiposocio, NEW.qualificacao, NEW.descrcargo, NEW.valornominalcotas, NEW.percentcotas, NEW.quantcotas, NEW.participaassis, NEW.ordemassis, NEW.declarafisicaescrit, NEW.qualificacaosocio, NEW.socioostensivo, NEW.datainiciosocio, NEW.datafimsocio, NEW.numeroinscrinss, NEW.codigoorgaoemissorrg, NEW.pissocio, NEW.numerorg, NEW.siglaestadorg, NEW.datarg, NEW.tituloeleitornumero, NEW.tituloeleitorzona, NEW.tituloeleitorsecao, NEW.datanasc, NEW.siglaestadonasc, NEW.codigomunicnasc, NEW.nacionalidade, NEW.grauinstr, NEW.formacao, NEW.estadocivil, NEW.regimecasamento, NEW.maiormenoridade, NEW.nomerepreslegal, NEW.cpfrespreslegal, NEW.qualifrespreslegal, NEW.nomemae, NEW.inscrfederalmae, NEW.datanascmae, NEW.nomepai, NEW.inscrfederalpai, NEW.statussinczen, NEW.datanascpai, NEW.tipoalteracaoesocial, NEW.idsocioqn, NEW.statussinczenii); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="sociobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.sociobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, CODIGOEMPRESA, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, OLD.CODIGOEMPRESA, &apos;SOCIOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO SOCIOHS(SEQHISTORICO, OPERACAO, codigoempresa, codigosocio, datainicial, nomesocio, tipoinscr, codigotipolograd, inscrfederal, enderecosocio, numendersocio, complendersocio, bairroendersocio, siglaestado, codigomunic, cependersocio, dddfone, numerofone, ramal, dddfax, dddcelular, numerocelular, numerofax, email, resplegal, perfiltareffa, tiposocio, qualificacao, descrcargo, valornominalcotas, percentcotas, quantcotas, participaassis, ordemassis, declarafisicaescrit, qualificacaosocio, socioostensivo, datainiciosocio, datafimsocio, numeroinscrinss, codigoorgaoemissorrg, pissocio, numerorg, siglaestadorg, datarg, tituloeleitornumero, tituloeleitorzona, tituloeleitorsecao, datanasc, siglaestadonasc, codigomunicnasc, nacionalidade, grauinstr, formacao, estadocivil, regimecasamento, maiormenoridade, nomerepreslegal, cpfrespreslegal, qualifrespreslegal, nomemae, inscrfederalmae, datanascmae, nomepai, inscrfederalpai, statussinczen, datanascpai, tipoalteracaoesocial, idsocioqn, statussinczenii) &#013;&#010;  VALUES (GEN, 4, OLD.codigoempresa, OLD.codigosocio, OLD.datainicial, OLD.nomesocio, OLD.tipoinscr, OLD.codigotipolograd, OLD.inscrfederal, OLD.enderecosocio, OLD.numendersocio, OLD.complendersocio, OLD.bairroendersocio, OLD.siglaestado, OLD.codigomunic, OLD.cependersocio, OLD.dddfone, OLD.numerofone, OLD.ramal, OLD.dddfax, OLD.dddcelular, OLD.numerocelular, OLD.numerofax, OLD.email, OLD.resplegal, OLD.perfiltareffa, OLD.tiposocio, OLD.qualificacao, OLD.descrcargo, OLD.valornominalcotas, OLD.percentcotas, OLD.quantcotas, OLD.participaassis, OLD.ordemassis, OLD.declarafisicaescrit, OLD.qualificacaosocio, OLD.socioostensivo, OLD.datainiciosocio, OLD.datafimsocio, OLD.numeroinscrinss, OLD.codigoorgaoemissorrg, OLD.pissocio, OLD.numerorg, OLD.siglaestadorg, OLD.datarg, OLD.tituloeleitornumero, OLD.tituloeleitorzona, OLD.tituloeleitorsecao, OLD.datanasc, OLD.siglaestadonasc, OLD.codigomunicnasc, OLD.nacionalidade, OLD.grauinstr, OLD.formacao, OLD.estadocivil, OLD.regimecasamento, OLD.maiormenoridade, OLD.nomerepreslegal, OLD.cpfrespreslegal, OLD.qualifrespreslegal, OLD.nomemae, OLD.inscrfederalmae, OLD.datanascmae, OLD.nomepai, OLD.inscrfederalpai, OLD.statussinczen, OLD.datanascpai, OLD.tipoalteracaoesocial, OLD.idsocioqn, OLD.statussinczenii); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="subtrairsaldobd" procedure_source="CREATE OR REPLACE PROCEDURE public.subtrairsaldobd(pcodigoempresa smallint, pcodigoestab smallint, pcontactb numeric, pdatasaldo date, ptipolancamento character, pvalordeb numeric, pvalorcred numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;ADATASALDOMENSAL date;&#013;&#010;BEGIN&#013;&#010;  aDatASaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM pDatASaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM pDatASaldo) AS DATE);&#013;&#010;&#013;&#010;  UPDATE SALDOCTB&#013;&#010;     SET ValorDeb  = ValorDeb  - pValorDeb,&#013;&#010;         ValorCred = ValorCred - pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = pDatASaldo&#013;&#010;     AND TipoLancamento = pTipoLancamento;&#013;&#010;  UPDATE SALDOCTBMENSAL&#013;&#010;     SET ValorDeb  = ValorDeb  - pValorDeb,&#013;&#010;         ValorCred = ValorCred - pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = aDatASaldoMensal&#013;&#010;     AND TipoLancamento = pTipoLancamento;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="subtrairsaldobdhist" procedure_source="CREATE OR REPLACE PROCEDURE public.subtrairsaldobdhist(pcodigoempresa smallint, pcodigoestab smallint, pcontactb numeric, pdatasaldo date, ptipolancamento character, pcodigohistctb smallint, pvalordeb numeric, pvalorcred numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;ADATASALDOMENSAL date;&#013;&#010;BEGIN&#013;&#010;  aDatASaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM pDatASaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM pDatASaldo) AS DATE);&#013;&#010;&#013;&#010;  UPDATE SALDOCTBMENSALHIST&#013;&#010;     SET ValorDeb  = ValorDeb  - pValorDeb,&#013;&#010;         ValorCred = ValorCred - pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = aDatASaldoMensal&#013;&#010;     AND TipoLancamento = pTipoLancamento&#013;&#010;     AND CodigoHIStCtb  = pCodigoHIStCtb;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="subtrairsaldobdmoeda" procedure_source="CREATE OR REPLACE PROCEDURE public.subtrairsaldobdmoeda(pcodigoempresa smallint, pcodigoestab smallint, pcontactb numeric, pdatasaldo date, ptipolancamento character, pcodigomoeda smallint, pvalordeb numeric, pvalorcred numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;ADATASALDOMENSAL date;&#013;&#010;BEGIN&#013;&#010;  aDatASaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM pDatASaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM pDatASaldo) AS DATE);&#013;&#010;&#013;&#010;  UPDATE SALDOCTBMOEDA&#013;&#010;     SET ValorDeb  = ValorDeb  - pValorDeb,&#013;&#010;         ValorCred = ValorCred - pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = pDatASaldo&#013;&#010;     AND TipoLancamento = pTipoLancamento&#013;&#010;     AND CodigoMoeda    = pCodigoMoeda;&#013;&#010;&#013;&#010;  UPDATE SALDOCTBMOEDAMENSAL&#013;&#010;     SET ValorDeb  = ValorDeb  - pValorDeb,&#013;&#010;         ValorCred = ValorCred - pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = aDatASaldoMensal&#013;&#010;     AND TipoLancamento = pTipoLancamento&#013;&#010;     AND CodigoMoeda    = pCodigoMoeda;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="subtrairsaldoctb" procedure_source="CREATE OR REPLACE PROCEDURE public.subtrairsaldoctb(pcodigoempresa smallint, pcodigoestab smallint, pcontactbdeb numeric, pcontactbcred numeric, pdatasaldo date, ptipolancamento character, pvalorsaldoctb numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;BEGIN&#013;&#010;IF (pContaCtbDeb IS NOT NULL) THEN&#013;&#010;CALL SUBTRAIRSALDOBD(pCodigoEmpresa, pCodigoEstab, &#013;&#010;pContaCtbDeb, pDatASaldo, pTipoLancamento, pValorSaldoCtb, 0);&#013;&#010;END IF;&#013;&#010;IF (pContaCtbCred IS NOT NULL) THEN&#013;&#010;CALL SUBTRAIRSALDOBD(pCodigoEmpresa, pCodigoEstab,&#013;&#010;        pContaCtbCred, pDatASaldo, pTipoLancamento, 0, pValorSaldoCtb);&#013;&#010;END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="subtrairsaldoctbhist" procedure_source="CREATE OR REPLACE PROCEDURE public.subtrairsaldoctbhist(pcodigoempresa smallint, pcodigoestab smallint, pcontactbdeb numeric, pcontactbcred numeric, pdatasaldo date, ptipolancamento character, pcodigohistctb smallint, pvalorsaldoctb numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;BEGIN&#013;&#010;  IF (pCodigoHIStCtb IS NOT NULL) THEN&#013;&#010;    IF (pContaCtbDeb IS NOT NULL) THEN&#013;&#010;      CALL SUBTRAIRSALDOBDHIST(pCodigoEmpresa, pCodigoEstab, pContaCtbDeb, &#013;&#010;  pDatASaldo, pTipoLancamento, pCodigoHIStCtb, pValorSaldoCtb, 0);&#013;&#010;    END IF;&#013;&#010;    IF (pContaCtbCred IS NOT NULL) THEN&#013;&#010;      CALL SUBTRAIRSALDOBDHIST(pCodigoEmpresa, pCodigoEstab, pContaCtbCred,&#013;&#010;      pDatASaldo, pTipoLancamento, pCodigoHIStCtb, 0, pValorSaldoCtb);&#013;&#010;END IF;&#013;&#010;  END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="subtrairsaldoctbmoeda" procedure_source="CREATE OR REPLACE PROCEDURE public.subtrairsaldoctbmoeda(pcodigoempresa smallint, pcodigoestab smallint, pcontactbdeb numeric, pcontactbcred numeric, pdatasaldo date, ptipolancamento character, pvalorlctomoeda numeric, pcodigomoedalcto smallint)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;AMOEDAFUNCIONAL smallint;&#013;&#010;BEGIN&#013;&#010;  IF (pValorLctoMoeda IS NOT NULL) THEN&#013;&#010;    aMoedaFuncional = pCodigoMoedaLcto;&#013;&#010;    IF (aMoedaFuncional IS NULL) THEN&#013;&#010;SELECT CODIGOMOEDA FROM CARREGARMOEDAFUNCIONAL(pCodigoEmpresa, pCodigoEstab, pDatASaldo) INTO aMoedaFuncional;&#013;&#010;IF (aMoedaFuncional IS NOT NULL) THEN&#013;&#010;IF (pContaCtbDeb IS NOT NULL) THEN&#013;&#010;CALL SUBTRAIRSALDOBDMOEDA(pCodigoEmpresa, pCodigoEstab, pContaCtbDeb,&#013;&#010;                pDatASaldo, pTipoLancamento, aMoedaFuncional, pValorLctoMoeda, 0);&#013;&#010;END IF;&#013;&#010;IF (pContaCtbCred IS NOT NULL) THEN&#013;&#010;CALL SUBTRAIRSALDOBDMOEDA(pCodigoEmpresa, pCodigoEstab, pContaCtbCred,&#013;&#010;                pDatASaldo, pTipoLancamento, aMoedaFuncional, 0, pValorLctoMoeda);&#013;&#010;END IF;&#013;&#010;END IF;&#013;&#010;    END IF;&#013;&#010;  END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="terceiroaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.terceiroaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TERCEIROHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TERCEIROHS(SEQHISTORICO, OPERACAO, codigoterc, nometerc, apelidoterc, datanasc, sexo, estadocivil, grauinstr, nacionalidade, anochegada, tipovisto, cartrne, validrne, cpfterc, pisterc, datacadpis, numeroctps, siglaestadoctps, expedctps, numerorg, orgemisrg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhterc, categcnh, validcnh, cartreserv, categcartreserv, datahoracadast, emitircarne, numeroinscrinss, formacarne, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigocargo, codigoconselho, numeroregist, dataregist, logradterc, enderterc, numeroender, complender, bairroterc, siglaestado, codigomunic, cepterc, dddfone, numerofone, ramalfone, endereletr, categoria, codigotipocontr, salcarne, multvincterc, formacalculoirrf, observterc, produtrural, seriectps, inscrprod, categesocial, utilizaservicovariavel, indnumeroidentfiscal, numeroidentfiscal, frmtribut) &#013;&#010;  VALUES (GEN, 1, NEW.codigoterc, NEW.nometerc, NEW.apelidoterc, NEW.datanasc, NEW.sexo, NEW.estadocivil, NEW.grauinstr, NEW.nacionalidade, NEW.anochegada, NEW.tipovisto, NEW.cartrne, NEW.validrne, NEW.cpfterc, NEW.pisterc, NEW.datacadpis, NEW.numeroctps, NEW.siglaestadoctps, NEW.expedctps, NEW.numerorg, NEW.orgemisrg, NEW.siglaestadorg, NEW.emissrg, NEW.titeleit, NEW.zonatiteleit, NEW.secaotiteleit, NEW.cnhterc, NEW.categcnh, NEW.validcnh, NEW.cartreserv, NEW.categcartreserv, NEW.datahoracadast, NEW.emitircarne, NEW.numeroinscrinss, NEW.formacarne, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigoimposto13, NEW.variacaoimposto13, NEW.codigocargo, NEW.codigoconselho, NEW.numeroregist, NEW.dataregist, NEW.logradterc, NEW.enderterc, NEW.numeroender, NEW.complender, NEW.bairroterc, NEW.siglaestado, NEW.codigomunic, NEW.cepterc, NEW.dddfone, NEW.numerofone, NEW.ramalfone, NEW.endereletr, NEW.categoria, NEW.codigotipocontr, NEW.salcarne, NEW.multvincterc, NEW.formacalculoirrf, NEW.observterc, NEW.produtrural, NEW.seriectps, NEW.inscrprod, NEW.categesocial, NEW.utilizaservicovariavel, NEW.indnumeroidentfiscal, NEW.numeroidentfiscal, NEW.frmtribut); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="terceiroauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.terceiroauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TERCEIROHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TERCEIROHS(SEQHISTORICO, OPERACAO, codigoterc, nometerc, apelidoterc, datanasc, sexo, estadocivil, grauinstr, nacionalidade, anochegada, tipovisto, cartrne, validrne, cpfterc, pisterc, datacadpis, numeroctps, siglaestadoctps, expedctps, numerorg, orgemisrg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhterc, categcnh, validcnh, cartreserv, categcartreserv, datahoracadast, emitircarne, numeroinscrinss, formacarne, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigocargo, codigoconselho, numeroregist, dataregist, logradterc, enderterc, numeroender, complender, bairroterc, siglaestado, codigomunic, cepterc, dddfone, numerofone, ramalfone, endereletr, categoria, codigotipocontr, salcarne, multvincterc, formacalculoirrf, observterc, produtrural, seriectps, inscrprod, categesocial, utilizaservicovariavel, indnumeroidentfiscal, numeroidentfiscal, frmtribut) &#013;&#010;  VALUES (GEN, 2, OLD.codigoterc, OLD.nometerc, OLD.apelidoterc, OLD.datanasc, OLD.sexo, OLD.estadocivil, OLD.grauinstr, OLD.nacionalidade, OLD.anochegada, OLD.tipovisto, OLD.cartrne, OLD.validrne, OLD.cpfterc, OLD.pisterc, OLD.datacadpis, OLD.numeroctps, OLD.siglaestadoctps, OLD.expedctps, OLD.numerorg, OLD.orgemisrg, OLD.siglaestadorg, OLD.emissrg, OLD.titeleit, OLD.zonatiteleit, OLD.secaotiteleit, OLD.cnhterc, OLD.categcnh, OLD.validcnh, OLD.cartreserv, OLD.categcartreserv, OLD.datahoracadast, OLD.emitircarne, OLD.numeroinscrinss, OLD.formacarne, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigoimposto13, OLD.variacaoimposto13, OLD.codigocargo, OLD.codigoconselho, OLD.numeroregist, OLD.dataregist, OLD.logradterc, OLD.enderterc, OLD.numeroender, OLD.complender, OLD.bairroterc, OLD.siglaestado, OLD.codigomunic, OLD.cepterc, OLD.dddfone, OLD.numerofone, OLD.ramalfone, OLD.endereletr, OLD.categoria, OLD.codigotipocontr, OLD.salcarne, OLD.multvincterc, OLD.formacalculoirrf, OLD.observterc, OLD.produtrural, OLD.seriectps, OLD.inscrprod, OLD.categesocial, OLD.utilizaservicovariavel, OLD.indnumeroidentfiscal, OLD.numeroidentfiscal, OLD.frmtribut); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TERCEIROHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TERCEIROHS(SEQHISTORICO, OPERACAO, codigoterc, nometerc, apelidoterc, datanasc, sexo, estadocivil, grauinstr, nacionalidade, anochegada, tipovisto, cartrne, validrne, cpfterc, pisterc, datacadpis, numeroctps, siglaestadoctps, expedctps, numerorg, orgemisrg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhterc, categcnh, validcnh, cartreserv, categcartreserv, datahoracadast, emitircarne, numeroinscrinss, formacarne, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigocargo, codigoconselho, numeroregist, dataregist, logradterc, enderterc, numeroender, complender, bairroterc, siglaestado, codigomunic, cepterc, dddfone, numerofone, ramalfone, endereletr, categoria, codigotipocontr, salcarne, multvincterc, formacalculoirrf, observterc, produtrural, seriectps, inscrprod, categesocial, utilizaservicovariavel, indnumeroidentfiscal, numeroidentfiscal, frmtribut) &#013;&#010;  VALUES (GEN, 3, NEW.codigoterc, NEW.nometerc, NEW.apelidoterc, NEW.datanasc, NEW.sexo, NEW.estadocivil, NEW.grauinstr, NEW.nacionalidade, NEW.anochegada, NEW.tipovisto, NEW.cartrne, NEW.validrne, NEW.cpfterc, NEW.pisterc, NEW.datacadpis, NEW.numeroctps, NEW.siglaestadoctps, NEW.expedctps, NEW.numerorg, NEW.orgemisrg, NEW.siglaestadorg, NEW.emissrg, NEW.titeleit, NEW.zonatiteleit, NEW.secaotiteleit, NEW.cnhterc, NEW.categcnh, NEW.validcnh, NEW.cartreserv, NEW.categcartreserv, NEW.datahoracadast, NEW.emitircarne, NEW.numeroinscrinss, NEW.formacarne, NEW.codigoimposto, NEW.variacaoimposto, NEW.codigoimposto13, NEW.variacaoimposto13, NEW.codigocargo, NEW.codigoconselho, NEW.numeroregist, NEW.dataregist, NEW.logradterc, NEW.enderterc, NEW.numeroender, NEW.complender, NEW.bairroterc, NEW.siglaestado, NEW.codigomunic, NEW.cepterc, NEW.dddfone, NEW.numerofone, NEW.ramalfone, NEW.endereletr, NEW.categoria, NEW.codigotipocontr, NEW.salcarne, NEW.multvincterc, NEW.formacalculoirrf, NEW.observterc, NEW.produtrural, NEW.seriectps, NEW.inscrprod, NEW.categesocial, NEW.utilizaservicovariavel, NEW.indnumeroidentfiscal, NEW.numeroidentfiscal, NEW.frmtribut); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="terceirobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.terceirobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TERCEIROHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TERCEIROHS(SEQHISTORICO, OPERACAO, codigoterc, nometerc, apelidoterc, datanasc, sexo, estadocivil, grauinstr, nacionalidade, anochegada, tipovisto, cartrne, validrne, cpfterc, pisterc, datacadpis, numeroctps, siglaestadoctps, expedctps, numerorg, orgemisrg, siglaestadorg, emissrg, titeleit, zonatiteleit, secaotiteleit, cnhterc, categcnh, validcnh, cartreserv, categcartreserv, datahoracadast, emitircarne, numeroinscrinss, formacarne, codigoimposto, variacaoimposto, codigoimposto13, variacaoimposto13, codigocargo, codigoconselho, numeroregist, dataregist, logradterc, enderterc, numeroender, complender, bairroterc, siglaestado, codigomunic, cepterc, dddfone, numerofone, ramalfone, endereletr, categoria, codigotipocontr, salcarne, multvincterc, formacalculoirrf, observterc, produtrural, seriectps, inscrprod, categesocial, utilizaservicovariavel, indnumeroidentfiscal, numeroidentfiscal, frmtribut) &#013;&#010;  VALUES (GEN, 4, OLD.codigoterc, OLD.nometerc, OLD.apelidoterc, OLD.datanasc, OLD.sexo, OLD.estadocivil, OLD.grauinstr, OLD.nacionalidade, OLD.anochegada, OLD.tipovisto, OLD.cartrne, OLD.validrne, OLD.cpfterc, OLD.pisterc, OLD.datacadpis, OLD.numeroctps, OLD.siglaestadoctps, OLD.expedctps, OLD.numerorg, OLD.orgemisrg, OLD.siglaestadorg, OLD.emissrg, OLD.titeleit, OLD.zonatiteleit, OLD.secaotiteleit, OLD.cnhterc, OLD.categcnh, OLD.validcnh, OLD.cartreserv, OLD.categcartreserv, OLD.datahoracadast, OLD.emitircarne, OLD.numeroinscrinss, OLD.formacarne, OLD.codigoimposto, OLD.variacaoimposto, OLD.codigoimposto13, OLD.variacaoimposto13, OLD.codigocargo, OLD.codigoconselho, OLD.numeroregist, OLD.dataregist, OLD.logradterc, OLD.enderterc, OLD.numeroender, OLD.complender, OLD.bairroterc, OLD.siglaestado, OLD.codigomunic, OLD.cepterc, OLD.dddfone, OLD.numerofone, OLD.ramalfone, OLD.endereletr, OLD.categoria, OLD.codigotipocontr, OLD.salcarne, OLD.multvincterc, OLD.formacalculoirrf, OLD.observterc, OLD.produtrural, OLD.seriectps, OLD.inscrprod, OLD.categesocial, OLD.utilizaservicovariavel, OLD.indnumeroidentfiscal, OLD.numeroidentfiscal, OLD.frmtribut); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="tipocontratoaihsf" procedure_source="CREATE OR REPLACE FUNCTION public.tipocontratoaihsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TIPOCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TIPOCONTRATOHS(SEQHISTORICO, OPERACAO, descrtipocontr, codigotipocontr, tipocontr, categoria, calculainss, calculainssemp, calculairrf, calculafgts, percfgts, percadicfgts, calculapis, constarais, codigodirferias, codigotabinss, constacaged, constasefip, proporccalculo13dia, proporccalculoferiasdia, categesocial, vinculo, calculavaletransp, bolsista) &#013;&#010;  VALUES (GEN, 1, NEW.descrtipocontr, NEW.codigotipocontr, NEW.tipocontr, NEW.categoria, NEW.calculainss, NEW.calculainssemp, NEW.calculairrf, NEW.calculafgts, NEW.percfgts, NEW.percadicfgts, NEW.calculapis, NEW.constarais, NEW.codigodirferias, NEW.codigotabinss, NEW.constacaged, NEW.constasefip, NEW.proporccalculo13dia, NEW.proporccalculoferiasdia, NEW.categesocial, NEW.vinculo, NEW.calculavaletransp, NEW.bolsista); &#013;&#010;&#013;&#010;RETURN NEW; &#013;&#010;END &#013;&#010;$function$&#010;"/>
<ROW pro_key="tipocontratoauhsf" procedure_source="CREATE OR REPLACE FUNCTION public.tipocontratoauhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TIPOCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TIPOCONTRATOHS(SEQHISTORICO, OPERACAO, descrtipocontr, codigotipocontr, tipocontr, categoria, calculainss, calculainssemp, calculairrf, calculafgts, percfgts, percadicfgts, calculapis, constarais, codigodirferias, codigotabinss, constacaged, constasefip, proporccalculo13dia, proporccalculoferiasdia, categesocial, vinculo, calculavaletransp, bolsista) &#013;&#010;  VALUES (GEN, 2, OLD.descrtipocontr, OLD.codigotipocontr, OLD.tipocontr, OLD.categoria, OLD.calculainss, OLD.calculainssemp, OLD.calculairrf, OLD.calculafgts, OLD.percfgts, OLD.percadicfgts, OLD.calculapis, OLD.constarais, OLD.codigodirferias, OLD.codigotabinss, OLD.constacaged, OLD.constasefip, OLD.proporccalculo13dia, OLD.proporccalculoferiasdia, OLD.categesocial, OLD.vinculo, OLD.calculavaletransp, OLD.bolsista); &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TIPOCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TIPOCONTRATOHS(SEQHISTORICO, OPERACAO, descrtipocontr, codigotipocontr, tipocontr, categoria, calculainss, calculainssemp, calculairrf, calculafgts, percfgts, percadicfgts, calculapis, constarais, codigodirferias, codigotabinss, constacaged, constasefip, proporccalculo13dia, proporccalculoferiasdia, categesocial, vinculo, calculavaletransp, bolsista) &#013;&#010;  VALUES (GEN, 3, NEW.descrtipocontr, NEW.codigotipocontr, NEW.tipocontr, NEW.categoria, NEW.calculainss, NEW.calculainssemp, NEW.calculairrf, NEW.calculafgts, NEW.percfgts, NEW.percadicfgts, NEW.calculapis, NEW.constarais, NEW.codigodirferias, NEW.codigotabinss, NEW.constacaged, NEW.constasefip, NEW.proporccalculo13dia, NEW.proporccalculoferiasdia, NEW.categesocial, NEW.vinculo, NEW.calculavaletransp, NEW.bolsista); &#013;&#010;&#013;&#010;RETURN NEW; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="tipocontratobdhsf" procedure_source="CREATE OR REPLACE FUNCTION public.tipocontratobdhsf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$ &#013;&#010;DECLARE GEN INTEGER; &#013;&#010;BEGIN &#013;&#010;&#013;&#010;  SELECT NEXTVAL(&apos;gen_ordemhistorico&apos;) INTO GEN ; &#013;&#010;&#013;&#010;  INSERT INTO ORDEMHISTORICO(SEQHISTORICO, TABELAHISTORICO) &#013;&#010;  VALUES (GEN, &apos;TIPOCONTRATOHS&apos;); &#013;&#010;&#013;&#010;  INSERT INTO TIPOCONTRATOHS(SEQHISTORICO, OPERACAO, descrtipocontr, codigotipocontr, tipocontr, categoria, calculainss, calculainssemp, calculairrf, calculafgts, percfgts, percadicfgts, calculapis, constarais, codigodirferias, codigotabinss, constacaged, constasefip, proporccalculo13dia, proporccalculoferiasdia, categesocial, vinculo, calculavaletransp, bolsista) &#013;&#010;  VALUES (GEN, 4, OLD.descrtipocontr, OLD.codigotipocontr, OLD.tipocontr, OLD.categoria, OLD.calculainss, OLD.calculainssemp, OLD.calculairrf, OLD.calculafgts, OLD.percfgts, OLD.percadicfgts, OLD.calculapis, OLD.constarais, OLD.codigodirferias, OLD.codigotabinss, OLD.constacaged, OLD.constasefip, OLD.proporccalculo13dia, OLD.proporccalculoferiasdia, OLD.categesocial, OLD.vinculo, OLD.calculavaletransp, OLD.bolsista); &#013;&#010;&#013;&#010;RETURN OLD; END &#013;&#010;$function$&#010;"/>
<ROW pro_key="tlagendaconfigfuncacessof" procedure_source="CREATE OR REPLACE FUNCTION public.tlagendaconfigfuncacessof()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glagendaconfigfuncacesso&apos;);&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlagendaconfigfuncf" procedure_source="CREATE OR REPLACE FUNCTION public.tlagendaconfigfuncf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glagendaconfiguracaofunc&apos;);&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlagendaconfiguracaof" procedure_source="CREATE OR REPLACE FUNCTION public.tlagendaconfiguracaof()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glagendaconfiguracao&apos;);&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlambitotiposf" procedure_source="CREATE OR REPLACE FUNCTION public.tlambitotiposf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (new.ID is null) THEN&#013;&#010;new.ID = NEXTVAL(&apos;glambitotipos&apos;);/**/&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glambitotipos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glambitotipos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glambitotipos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlarquivosf" procedure_source="CREATE OR REPLACE FUNCTION public.tlarquivosf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glarquivos&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glarquivos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glarquivos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glarquivos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlatividadeocorrenciasf" procedure_source="CREATE OR REPLACE FUNCTION public.tlatividadeocorrenciasf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glatividadeocorrencias&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glatividadeocorrencias&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glatividadeocorrencias;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glatividadeocorrencias&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlatividadesf" procedure_source="CREATE OR REPLACE FUNCTION public.tlatividadesf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glatividades&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glatividades&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glatividades;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glatividades&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlatividadetiposf" procedure_source="CREATE OR REPLACE FUNCTION public.tlatividadetiposf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glatividadetipos&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glatividadetipos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glatividadetipos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glatividadetipos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlconfiguracaof" procedure_source="CREATE OR REPLACE FUNCTION public.tlconfiguracaof()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glconfiguracao&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glconfiguracao&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glconfiguracao;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glconfiguracao&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tldepartamentosf" procedure_source="CREATE OR REPLACE FUNCTION public.tldepartamentosf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;gldepartamentos&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;gldepartamentos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM gldepartamentos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;gldepartamentos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlescritoriosettingf" procedure_source="CREATE OR REPLACE FUNCTION public.tlescritoriosettingf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glescritoriosetting&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glescritoriosetting&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glescritoriosetting;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glescritoriosetting&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlfluxosf" procedure_source="CREATE OR REPLACE FUNCTION public.tlfluxosf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glfluxos&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glfluxos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glfluxos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glfluxos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlgruposf" procedure_source="CREATE OR REPLACE FUNCTION public.tlgruposf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glgrupos&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glgrupos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glgrupos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glgrupos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlocorrenciahistoricosf" procedure_source="CREATE OR REPLACE FUNCTION public.tlocorrenciahistoricosf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glocorrenciahistoricos&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glocorrenciahistoricos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glocorrenciahistoricos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glocorrenciahistoricos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlprocedimentosf" procedure_source="CREATE OR REPLACE FUNCTION public.tlprocedimentosf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glprocedimentos&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glprocedimentos&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glprocedimentos;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glprocedimentos&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="tlquestormenuf" procedure_source="CREATE OR REPLACE FUNCTION public.tlquestormenuf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#013;&#010;DECLARE &#013;&#010;i Numeric(14,0);&#013;&#010;BEGIN &#013;&#010;IF (NEW.ID is NULL) THEN &#013;&#010;NEW.ID = NEXTVAL(&apos;glquestormenu&apos;);&#013;&#010;ELSE&#013;&#010;BEGIN&#013;&#010;SELECT CURRVAL(&apos;glquestormenu&apos;) INTO i;&#013;&#010;EXCEPTION WHEN OTHERS THEN&#013;&#010;SELECT last_value INTO i FROM glquestormenu;&#013;&#010;END;&#013;&#010;WHILE (NEW.ID &gt; i) LOOP &#013;&#010;SELECT nextval(&apos;glquestormenu&apos;) INTO i;&#013;&#010;END LOOP;&#013;&#010;END IF;&#013;&#010;RETURN NEW;&#013;&#010;END;&#013;&#010;$function$&#010;"/>
<ROW pro_key="totalizarsaldobd" procedure_source="CREATE OR REPLACE PROCEDURE public.totalizarsaldobd(pcodigoempresa smallint, pcodigoestab smallint, pcontactb numeric, pdatasaldo date, ptipolancamento character, pvalordeb numeric, pvalorcred numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;ADATASALDOMENSAL date;&#013;&#010;BEGIN&#013;&#010;  aDatASaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM pDatASaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM pDatASaldo) AS DATE);&#013;&#010;  UPDATE SALDOCTB&#013;&#010;     SET ValorDeb  = ValorDeb  + pValorDeb,&#013;&#010;         ValorCred = ValorCred + pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = pDatASaldo&#013;&#010;     AND TipoLancamento = pTipoLancamento;&#013;&#010;  IF NOT FOUND THEN&#013;&#010;    INSERT INTO SALDOCTB (CodigoEmpresa, CodigoEstab, ContaCtb,&#013;&#010;    DatASaldo, TipoLancamento, ValorDeb, ValorCred)&#013;&#010;        values (pCodigoEmpresa, pCodigoEstab, pContaCtb,&#013;&#010;    pDatASaldo, pTipoLancamento, pValorDeb, pValorCred);&#013;&#010;  END IF;&#013;&#010;  UPDATE SALDOCTBMENSAL&#013;&#010;     SET ValorDeb  = ValorDeb  + pValorDeb,&#013;&#010;         ValorCred = ValorCred + pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = aDatASaldoMensal&#013;&#010;     AND TipoLancamento = pTipoLancamento;&#013;&#010;  IF NOT FOUND THEN&#013;&#010;    INSERT INTO SALDOCTBMENSAL (CodigoEmpresa, CodigoEstab, ContaCtb,&#013;&#010;    DatASaldo, TipoLancamento, ValorDeb, ValorCred)&#013;&#010;        values (pCodigoEmpresa, pCodigoEstab, pContaCtb, &#013;&#010;aDatASaldoMensal, pTipoLancamento, pValorDeb, pValorCred);&#013;&#010;  END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="totalizarsaldobdhist" procedure_source="CREATE OR REPLACE PROCEDURE public.totalizarsaldobdhist(pcodigoempresa smallint, pcodigoestab smallint, pcontactb numeric, pdatasaldo date, ptipolancamento character, pcodigohistctb smallint, pvalordeb numeric, pvalorcred numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;ADATASALDOMENSAL date;&#013;&#010;BEGIN&#013;&#010;  aDatASaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM pDatASaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM pDatASaldo) AS DATE);&#013;&#010;  UPDATE SALDOCTBMENSALHIST&#013;&#010;     SET ValorDeb  = ValorDeb  + pValorDeb,&#013;&#010;         ValorCred = ValorCred + pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = aDatASaldoMensal&#013;&#010;     AND TipoLancamento = pTipoLancamento&#013;&#010;     AND CodigoHIStCtb  = pCodigoHIStCtb;&#013;&#010;  IF NOT FOUND/*(row_count = 0)*/ THEN&#013;&#010;    INSERT INTO SALDOCTBMENSALHIST (CodigoEmpresa, CodigoEstab, ContaCtb,&#013;&#010;    DatASaldo, TipoLancamento, CodigoHIStCtb, ValorDeb, ValorCred)&#013;&#010;        values (pCodigoEmpresa, pCodigoEstab, pContaCtb, aDatASaldoMensal,&#013;&#010;    pTipoLancamento, pCodigoHIStCtb, pValorDeb, pValorCred);&#013;&#010;  END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="totalizarsaldobdmoeda" procedure_source="CREATE OR REPLACE PROCEDURE public.totalizarsaldobdmoeda(pcodigoempresa smallint, pcodigoestab smallint, pcontactb numeric, pdatasaldo date, ptipolancamento character, pcodigomoeda smallint, pvalordeb numeric, pvalorcred numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;ADATASALDOMENSAL date;&#013;&#010;BEGIN&#013;&#010;  aDatASaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM pDatASaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM pDatASaldo) AS DATE);&#013;&#010;  UPDATE SALDOCTBMOEDA&#013;&#010;     SET ValorDeb  = ValorDeb  + pValorDeb,&#013;&#010;         ValorCred = ValorCred + pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = pDatASaldo&#013;&#010;     AND TipoLancamento = pTipoLancamento&#013;&#010;     AND CodigoMoeda    = pCodigoMoeda;&#013;&#010;  IF NOT FOUND /*(row_count = 0)*/ THEN&#013;&#010;    INSERT INTO SALDOCTBMOEDA (CodigoEmpresa, CodigoEstab, ContaCtb,&#013;&#010;    DatASaldo, TipoLancamento, CodigoMoeda, ValorDeb, ValorCred)&#013;&#010;        values (pCodigoEmpresa, pCodigoEstab, pContaCtb, pDatASaldo,&#013;&#010;    pTipoLancamento, pCodigoMoeda, pValorDeb, pValorCred);&#013;&#010;  END IF;&#013;&#010;  UPDATE SALDOCTBMOEDAMENSAL&#013;&#010;     SET ValorDeb  = ValorDeb  + pValorDeb,&#013;&#010;         ValorCred = ValorCred + pValorCred&#013;&#010;   WHERE CodigoEmpresa  = pCodigoEmpresa&#013;&#010;     AND CodigoEstab    = pCodigoEstab&#013;&#010;     AND ContaCtb       = pContaCtb&#013;&#010;     AND DatASaldo      = aDatASaldoMensal&#013;&#010;     AND TipoLancamento = pTipoLancamento&#013;&#010;     AND CodigoMoeda    = pCodigoMoeda;&#013;&#010;  IF NOT FOUND /*(row_count = 0)*/ THEN&#013;&#010;    INSERT INTO SALDOCTBMOEDAMENSAL (CodigoEmpresa, CodigoEstab, ContaCtb,&#013;&#010;    DatASaldo, TipoLancamento, CodigoMoeda, ValorDeb, ValorCred)&#013;&#010;        values (pCodigoEmpresa, pCodigoEstab, pContaCtb, aDatASaldoMensal,&#013;&#010;    pTipoLancamento, pCodigoMoeda, pValorDeb, pValorCred);&#013;&#010;  END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="totalizarsaldoctb" procedure_source="CREATE OR REPLACE PROCEDURE public.totalizarsaldoctb(pcodigoempresa smallint, pcodigoestab smallint, pcontactbdeb numeric, pcontactbcred numeric, pdatasaldo date, ptipolancamento character, pvalorsaldoctb numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;BEGIN&#013;&#010;  IF (pContaCtbDeb IS NOT NULL) THEN&#013;&#010;    CALL TOTALIZARSALDOBD(pCodigoEmpresa, pCodigoEstab,&#013;&#010;    pContaCtbDeb, pDatASaldo, pTipoLancamento, pValorSaldoCtb, 0);&#013;&#010;  END IF;&#013;&#010;  IF (pContaCtbCred IS NOT NULL) THEN&#013;&#010;    CALL TOTALIZARSALDOBD(pCodigoEmpresa, pCodigoEstab, &#013;&#010;pContaCtbCred, pDatASaldo, pTipoLancamento, 0, pValorSaldoCtb);&#013;&#010;  END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="totalizarsaldoctbhist" procedure_source="CREATE OR REPLACE PROCEDURE public.totalizarsaldoctbhist(pcodigoempresa smallint, pcodigoestab smallint, pcontactbdeb numeric, pcontactbcred numeric, pdatasaldo date, ptipolancamento character, pcodigohistctb smallint, pvalorsaldoctb numeric)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;BEGIN&#013;&#010;IF (pCodigoHIStCtb IS NOT NULL) THEN&#013;&#010;IF (pContaCtbDeb IS NOT NULL) THEN&#013;&#010;CALL TOTALIZARSALDOBDHIST(pCodigoEmpresa, pCodigoEstab, pContaCtbDeb, &#013;&#010;pDatASaldo, pTipoLancamento, pCodigoHIStCtb, pValorSaldoCtb, 0);&#013;&#010;END IF;&#013;&#010;IF (pContaCtbCred IS NOT NULL) THEN&#013;&#010;CALL TOTALIZARSALDOBDHIST(pCodigoEmpresa, pCodigoEstab, pContaCtbCred,&#013;&#010;            pDatASaldo, pTipoLancamento, pCodigoHIStCtb, 0, pValorSaldoCtb);&#013;&#010;END IF;&#013;&#010;END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="totalizarsaldoctbmoeda" procedure_source="CREATE OR REPLACE PROCEDURE public.totalizarsaldoctbmoeda(pcodigoempresa smallint, pcodigoestab smallint, pcontactbdeb numeric, pcontactbcred numeric, pdatasaldo date, ptipolancamento character, pvalorlctomoeda numeric, pcodigomoedalcto smallint)&#010; LANGUAGE plpgsql&#010;AS $procedure$&#013;&#010;DECLARE &#013;&#010;AMOEDAFUNCIONAL smallint;&#013;&#010;BEGIN&#013;&#010;  IF (pValorLctoMoeda IS NOT NULL) THEN&#013;&#010;    aMoedaFuncional = pCodigoMoedaLcto;&#013;&#010;    IF (aMoedaFuncional IS NULL) THEN&#013;&#010;SELECT CODIGOMOEDA FROM CARREGARMOEDAFUNCIONAL(pCodigoEmpresa, pCodigoEstab, pDatASaldo) INTO aMoedaFuncional;&#013;&#010;IF (aMoedaFuncional IS NOT NULL) THEN&#013;&#010;IF (pContaCtbDeb IS NOT NULL) THEN&#013;&#010;CALL TOTALIZARSALDOBDMOEDA(pCodigoEmpresa, pCodigoEstab, pContaCtbDeb,&#013;&#010;                pDatASaldo, pTipoLancamento, aMoedaFuncional, pValorLctoMoeda, 0);&#013;&#010;END IF;&#013;&#010;IF (pContaCtbCred IS NOT NULL) THEN&#013;&#010;CALL TOTALIZARSALDOBDMOEDA(pCodigoEmpresa, pCodigoEstab, pContaCtbCred,&#013;&#010;                pDatASaldo, pTipoLancamento, aMoedaFuncional, 0, pValorLctoMoeda);&#013;&#010;END IF;&#013;&#010;END IF;&#013;&#010;    END IF;&#013;&#010;  END IF;&#013;&#010;END;&#013;&#010;$procedure$&#010;"/>
<ROW pro_key="zeramentoctbmoedaaiauf" procedure_source="CREATE OR REPLACE FUNCTION public.zeramentoctbmoedaaiauf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;CALL TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa, new.CodigoEstab, new.ContaCtbDeb,&#010;new.ContaCtbCred, new.DataZeramento, new.TipoLancamento, new.ValorZeramento, null);&#010;RETURN new;&#010;END; &#010;$function$&#010;"/>
<ROW pro_key="zeramentoctbmoedabubdf" procedure_source="CREATE OR REPLACE FUNCTION public.zeramentoctbmoedabubdf()&#010; RETURNS trigger&#010; LANGUAGE plpgsql&#010;AS $function$&#010;BEGIN&#010;CALL SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa, old.CodigoEstab, old.ContaCtbDeb,&#010;    old.ContaCtbCred, old.DataZeramento, old.TipoLancamento, old.ValorZeramento, null);&#010;RETURN old;&#010;END;&#010;$function$&#010;"/>
</ROWDATA>
</DATAPACKET>
