SET TERM ^ ;

create or alter procedure SPU_NFS_PARCELAMENTO_EMI
as
declare variable CONTROLE integer;
declare variable DATA_EMISSAO date;
BEGIN
   FOR SELECT
        T.CONTROLE,
        C.DATA_EMISSAO
    FROM TBNFS_PARCELAMENTO T
    INNER JOIN TBPDV_CFE C ON C.ID = T.PDV_CFE_ID
    WHERE T.DATA_EMISSAO <> C.DATA_EMISSAO
   INTO :CONTROLE, :DATA_EMISSAO
   DO BEGIN
        
        UPDATE TBNFS_PARCELAMENTO T SET T.DATA_EMISSAO = :DATA_EMISSAO WHERE T.CONTROLE = :CONTROLE;

   END
END
^

SET TERM ; ^

