Not sure if it should be expected behaviour but actually we expected it and it does not work like expected:
Inside a SQL macro (table) function i cannot access the value of a parameter, e. g.
function test(i_par varchar2) return varchar2 sql_macro as
begin
if i_par is null then
return 'select 1 from dual';
end if;
return 'select 0 from dual';
end test;
The value is always null.
If the parameter is numeric, it seems to work. Other datatypes don't work.
Another Problem when reading Package Variables inside the macro function:
function test return varchar2 sql_macro as
begin
if pub_param is null then
return 'select 1 from dual';
end if;
return 'select 0 from dual';
end test;
In the first call the right value gets cached. If you update the Package variable, the macro still returns the old statement.
Same problem if you select a parameter or get it by function like apex_util.get_session_state.