Functions cannot be invoked from Select Query : if the function is having any ddl/dml operations inside it.
create or replace function xx_temp_fun(p_deptno number)
insert into xx_dept(deptno,dname) values (p_deptno,'Bench') ;
select xx_temp_fun(21) from dual; --> this will give you an error. as the function written above is having DML operations inside it.
The follow works without any error.
v_char := xx_temp_fun(19);