Question : How to generate a sql report with dynamic report filter and display the results dynamically?

Hi all,
i need to do a sql report on reporting server. the requirements are:
1. dynamically input the report parameters:
eg: i have report parameters A and B, i can use either of them OR both of them as the report filter
2. dynamically display the results according to the report filter:
eg: if i use parameter A as the filter, then the report should display column a , b , c
if i use parameterB as the filter, then the report should display column a , b , c, d

Note: the database is Oracle 10g

how can i achieve this? i think i might have to use a store procedure to accept the report parameters and create the pl-sql query based on those parameters, but how can i output the result? use temp table? create different report for different parameter combination? can anyone point me to the correct direction?

thanks a lot

Answer : How to generate a sql report with dynamic report filter and display the results dynamically?

the above example didn't compile...  below example will compile

create or replace function f(p_a varchar2, p_b varchar2) return sys_refcursor
is
  retval sys_refcursor;
  report_query_a varchar2(4000) := 'select a , b , c from my_table where 1=1 ';
  report_query_b varchar2(4000) := 'select a , b , c, d from my_table where 1=1 ';
  report_query varchar2(4000);
begin

  --determine the columns to return
  if p_b is not null then
    report_query := report_query_b;
  else
    report_query := report_query_a;
  end if;

  --add the filters to the report query
  if p_a is not null then
    report_query := report_query||' and a = '''||p_a||'''';
  end if;
  if p_b is not null then
    report_query := report_query||' and b = '''||p_b||'''';
  end if;  
 
  open retval for report_query;
 
  return retval;
 
end;
/
Random Solutions  
 
programming4us programming4us