Skip to Main Content

Oracle Database Free

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!

Scalar Macros hate Aggragates

Mike KutzDec 6 2023

I didn't see in the documentation that you can't use an aggregate inside an sql_macro(scalar) .. or, at least, it's not stating it clearly. “A scalar macro cannot have table arguments.” – does this mean “No Aggregates”?

If I attempt to use an aggregate, I get:

ORA-00918: PRODUCT: column ambiguously specified - appears in and

create or replace
function product( P in  number ) return varchar2
  sql_macro(scalar)
as
begin
--  return '( EXP(SUM(LN( P ))) )'; -- fails
--  return '( sum(LN( P )) )';      -- fails
  return '( LN( P ) )';          -- works
end;
/

select product( d.T ) as abc
from (
  select 5 T union all
  select 6
) d;
This post has been answered by Chris Saxon-Oracle on Dec 7 2023
Jump to Answer
Comments
Post Details
Added on Dec 6 2023
5 comments
305 views