Question : Oracle 9i Reports question : Dynamic Reports

I want to be able to create a dynamic report, but do not want to necessarily pass arguments to my report using oracle forms.

Here is a sample sql of what I am trying to do:

SELECT ALL PERSON.PERSON_ID,
PERSON.FIRST_NAME, PERSON.LAST_NAME,
FROM PERSON
&W_CLAUSE

I have defined the object parameter W_CLAUSE in Object Navigator as well.

Basically, I have created my report. Now I want to be able to pass arguments to this reports dynamically (build the where clause dynamically). This information could be passed to this report using either an html, jsp, asp or even an oracle forms.

I have written the following procedure:

CREATE or REPLACE package reports is

     procedure run_report(where_clause VARCHAR2(50), person_id NUMBER);
END;

/

CREATE or REPLACE package body reports is

     PROCEDURE run_report(where_clause VARCHAR2(50), person_id NUMBER) is
       
             v_pl_id      PARAMETERLIST;
             v_pl_name    VARCHAR2(10) := 'my_list';
             v_rep_id     REPORT_OBJECT;
             v_rep_tx     VARCHAR2(100);
                 
     
     BEGIN
          -- delete paramter list if it currently exists
          v_pl_id := get_parameter_list(v_pl_name);
         
          IF NOT id_null(v_pl_id) THEN
               v_pl_id :- destroy_parameter_list(v_pl_id);
          END IF;
         
         
          -- create parameter list
          v_pl_id := create_parameter_list(v_pl_name);
         
          -- add parameters
          add_parameter(v_pl_id, 'where_clause', TEXT_PARAMETER, 'where person_id=' person_id);
         
          -- run report
          v_rep_id := find_report_object('my_report');
          v_rep_tx := run_report_object(v_rep_id, v_pl_id);
               

        END;  /* End of Procedure */
END;  /* End of package body */
/


Now, I have the following questions:

1) When I created the above report in Oracle Reports 9i, my report has been named MODULE2. Is that the name I should use instead of my_report in the procedure code above? If not, how should I save the above report in Oracle Reports?

2) Is there anything wrong with my approach? Do I need to change anything?

Thanks,
PF.

Answer : Oracle 9i Reports question : Dynamic Reports

What is "p_id"? If it's just a local variable for the package then you don't need the colon:
add_parameter(paramlist_id, 'person_id', TEXT_PARAMETER, p_id);

If it's a field in the form then you might want to pass it as a parameter to the package procedure, because I'm not sure if the program units in Forms can reference the fields directly.
Maybe that would be the best aproach for all cases - when you call the package procedure just pass as parameters all values that would be needed inside the package.
Hope that helps!
Random Solutions  
 
programming4us programming4us