tente assim: and (F.CDFRN = iif(:CDFRN is null, 0, :CDFRN)) and (F.CDCLI = iif(:CDCLI is null, 0, :CDCLI))