# F_MAX_NUM_EVENTI_CONFERMATI

## Codice Sorgente

```sql
FUNCTION F_MAX_NUM_EVENTI_CONFERMATI
(
  P_EVT_DATE IN DATE
, P_MAX_EVT_NUM NUMBER
, P_BYPASS IN NUMBER
) RETURN NUMBER AS 

    v_evt_cnt number;

BEGIN

    -- function bypass
    if P_BYPASS > 0 then
        return 0;
    end if;

    select
    count(e.id) as evt_cnt
    into v_evt_cnt
    from eventi e
    join vw_event_color c on c.id = e.id
    where e.data = P_EVT_DATE
    and c.status = 'Confermato';

    if v_evt_cnt >= P_MAX_EVT_NUM then
        return 1;
    else
        return 0;
    end if;

END F_MAX_NUM_EVENTI_CONFERMATI;```
