Document ID:        34680.1
Subject:            CALLING GRAPHICS FROM REPORTS
Author:             JHERNAND
Last Revision Date: 18 November  1996


                     Calling Graphics from Reports
                     =============================

Introduction
------------
This bulletin describes how to call Oracle Graphics 2.0/2.5 from
Oracle Reports 2.0/2.5 in a Master Detail report and update the graph
per department for the employee name and salary.

GRAPHICS 2.0/REPORTS 2.0
************************

Creating the Chart
------------------
Open Oracle Graphics 2.0, and follow the steps below:
1.  Choose File ==> Connect... Connect to Database

2.  Choose Control ==> Show Data Table... This opens a new screen.

3.  Choose File ==> New... This gives you a new query box.

4.  Verify that the name is set to query0 and the type is set to SQL Statement
    then press the OK button.

5.  Enter the SELECT statement for the graph (e.g. SELECT ename, sal FROM emp)
    then click on Query.

6.  Choose File ==> Exit

7.  Choose Control ==> Show Chart Template Editor

8.  From the menu item Chart, select the type of chart.

9.  Choose File ==> Close

10. From the Tool palette in the Designer, select the chart tool,
    create a chart and drag it to the desired size.

11. In the Chart Properties sheet, give the chart a name (e.g. emp).
    Verify that the template is set to 0 and the query is set to 0.
    Click on OK.  The graph then appears on the Designer.

12. Choose Control ==> Show PL/SQL Program Units

13. Click on the New button.  Enter the following trigger:
    PROCEDURE P1 IS
       q1  og_query;
       c1  og_object;
    BEGIN
       q1 := og_get_query('query0');
       c1 := og_get_object('emp');
       og_execute_query(q1);
       og_update_chart(c1, OG_ALL_CHUPDA);
    END;

    This trigger requeries the chart each time it is opened/called.  This
    procedure is important and is only needed for Graphics 2.0

14. Save the chart.

Creating the Report
-------------------
Open Oracle Reports 2.0, and follow the steps below:
1.  Choose File ==> Connect... Connect to Database

2.  In the Data Model, create the Master/Detail report...
    This example uses the dept and emp tables.

3.  Choose Report ==> Default Layout.  Choose the Master/Detail Style,
    and select the columns to show up in the report.

4.  Select the Master Frame and the Master Repeating Frame
    (e.g. M_1_GRPFRM, and R_1), and drag these to sizes to fit the chart.

5.  Select the Oracle Graphics Tool.
    In the Master Repeating Frame, drag the box to the desired chart size.

6.  Select the newly created box, and bring up its property sheet.
    In the property sheet, do the following:
    a.  Set the Display Name to the path and the saved chart name.
    b.  Set the Source to the Detail Group.
    c.  Select the Report column to be passed to the chart/
    d.  Enter the Chart column name that matches the Report column name.

7.  Save and run the report.  This produces a graph of employee names and
    their salaries based on department.

GRAPHICS 2.5/REPORTS 2.5
************************

Creating the Chart
------------------
Open Oracle Graphics 2.5, and follow the steps below:
1.  Choose File ==> Connect... Connect to Database

2.  Choose the file menu Chart ==> Create Chart...

3.  This brings up the Chart property sheet.  Go through the following steps:
    a.  Click on the Query Tab.
    b.  Verify the name is set to query0.
    c.  Verify the type is set to SQL Statement.
    d.  Enter the SQL statement in the block given.
        (e.g. SELECT ename, sal FROM emp)
    e.  Click on the Execute button.

4.  This populates the Data Tab.  Once this is populated, select OK.
    The Chart property sheet then appears.  Give the chart a name, and
    select the desired type of graph.  Select OK.

5.  The chart populated with the data appears on the Designer.

6.  Save the chart.

Creating the Report
-------------------
Open Oracle Reports 2.5 and follow the steps defined:
1.  Choose File ==> Connect... Connect to Database

2.  In the Data Model, create the Master/Detail report...
    This example uses the dept and emp tables.

3.  Choose Report ==> Default Layout.  Choose the Master/Detail
    Style, and select the columns to show up in the Report.

4.  Select the Master Frame and the Master Repeating Frame
    (e.g. M_1_GRPFRM, and R_1).  Drag these to sizes to fit the chart.

5.  Select the Oracle Graphics Tool and in the Master Repeating Frame.
    Drag out a box to the desired chart size.

6.  Select the newly created box, and bring up its property sheet.
    In the OG Display Tab, set the Display Name to the path and name
    of the saved chart.

7.  In the OG Query tab, do the following:
    a.  Set the Display Query to query0.
    b.  Set the Source to the Detail Group.
    c.  Select the Report column to be passed to the chart.
    d.  Enter the Chart column name that matches the Report column name.

8.  Save and run the report.  This produces a graph of employee names and
    their salaries based on department.