# F_DAY_TO_NAME

## Codice Sorgente

```sql
FUNCTION F_DAY_TO_NAME 
(
  DAY_NUMBER IN NUMBER 
) RETURN VARCHAR2 AS
    v_day_number number := DAY_NUMBER;
    v_language varchar2(255);
BEGIN
    with t as (
        select DECODE(parameter, 'NLS_CHARACTERSET', 'CHARACTER SET',
        'NLS_LANGUAGE', 'LANGUAGE',
        'NLS_TERRITORY', 'TERRITORY') name,
        value from v$nls_parameters
        WHERE parameter IN ( 'NLS_CHARACTERSET', 'NLS_LANGUAGE', 'NLS_TERRITORY')
    )
    select value into v_language
    from t
    where name = 'LANGUAGE';

    if v_language = 'AMERICAN' then
        case v_day_number
            when 1 then return 'Domenica';
            when 2 then return 'Lunedì';
            when 3 then return 'Martedì';
            when 4 then return 'Mercoledì';
            when 5 then return 'Giovedì';
            when 6 then return 'Venerdì';
            when 7 then return 'Sabato';
        end case;
    else
        case v_day_number
            when 1 then return 'Lunedì';
            when 2 then return 'Martedì';
            when 3 then return 'Mercoledì';
            when 4 then return 'Giovedì';
            when 5 then return 'Venerdì';
            when 6 then return 'Sabato';
            when 7 then return 'Domenica';
        end case;
    end if;
END F_DAY_TO_NAME;```
