procedure foo ( Xday number ) is nmatch number := 0; begin select count(*) into nmatchs from Whatever a where trunc(a.theDBdate + Xday) = trunc(sysdate); if nmatch > 0 then callSomeFunction(); end if; end;