Skip to Main Content

APEX

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ORA-20999: Parsing returned query results in "ORA-20999: Failed to parse SQL query! ORA-06550: line 4, column 24: ORA-00936:

Hello All,

I am getting this ora 20999 error when i execute the below code .

  • ORA-20999: Parsing returned query results in "ORA-20999: Failed to parse SQL query! ORA-06550: line 4, column 24: ORA-00936: missing expression".
declare
l_sql varchar2(32700);
group_col varchar2(3000);
begin 
for c1 in(
  select
    t1.column_name
  , t2.column_value
  from ALL_TAB_COLS t1
  left join table( apex_string.split( :P3_COLUMNS, ':' ) ) t2 on t1.column_name = t2.column_value
  where 1 = 1
    and owner='KK' and table_name='PWP_DEMOG'
) loop
  l_sql := l_sql || ',' || case when c1.column_value is not null then c1.column_name else 'null ' || c1.column_name end;
end loop;
select replace(:P3_COLUMNS,':',',') into group_col from dual;
l_sql := 'select distinct ' || ltrim( l_sql, ',' )  || ',count(distinct studyid) over (partition by '|| rtrim(group_col,',') ||') cnt '||
          ' 
          from kk.pwp_demog'  
          ;
          
           return l_sql;

This executes fine when i print the same in Text area with PL/SQL Function body as source.

select distinct DEM_RACE_ETHNICITY,CLINICAL_STAGE_AJCC,null CLINICAL_HER2,count(distinct studyid) over (partition by DEM_RACE_ETHNICITY,CLINICAL_STAGE_AJCC) cnt  
          from kk.pwp_demog

Can anyone please help me on identifying what is going wrong here.

Thanks!

Comments

Post Details

Added on May 10 2024
0 comments
386 views