CREATE OR ALTER procedure SPUI_MANIFESTACAO_CONFIRMACAO (
    CONFIRMACAO integer,
    MANIFESTO_ID integer)
as
BEGIN

    IN AUTONOMOUS TRANSACTION DO
    BEGIN
       UPDATE TBMANIFESTO_NF T SET T.CONFIRMACAO_EMPRESA = :CONFIRMACAO WHERE T.ID = :MANIFESTO_ID;

    END
END;

create or alter procedure SPUI_MANIFESTO_LOTE (
    MANIFESTO_ID integer,
    LOTE varchar(20),
    SEQUENCIAL integer,
    PROTOCOLO varchar(20),
    TIPO_EVENTO integer,
    DATAHORA timestamp,
    JUSTIFICATIVA varchar(100),
    USUARIO_ID integer)
as
BEGIN

    IN AUTONOMOUS TRANSACTION DO
    BEGIN
        UPDATE OR INSERT INTO TBMANIFESTO_LOTE (MANIFESTO_ID, LOTE, SEQUENCIAL, PROTOCOLO, TIPO_EVENTO, DATAHORA, JUSTIFICATIVA, USUARIO_ID)
                VALUES (:MANIFESTO_ID, :LOTE, :SEQUENCIAL, :PROTOCOLO, :TIPO_EVENTO, :DATAHORA, :JUSTIFICATIVA, :USUARIO_ID)
                MATCHING (MANIFESTO_ID, LOTE, SEQUENCIAL);

    END
END;