Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Access parameter values inside sql macro functions

rode_mbApr 11 2023

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.

Comments
Post Details
Added on Apr 11 2023
14 comments
1,415 views