Home » Developer & Programmer » Reports & Discoverer » Calling a chart from a report
|
Re: Calling a chart from a report [message #88282 is a reply to message #88274] |
Tue, 11 June 2002 06:28 |
Lars Sjöström
Messages: 24 Registered: June 2001
|
Junior Member |
|
|
Metalink says as follows:
Syntax for RUN_PRODUCT
----------------------
RUN_PRODUCT(product,document,commmode,execmode,location,list/name,display);
Product Specify the product to run.
Valid values are GRAPHICS, REPORTS, BOOK, and FORMS.
Document Specify the location of the Graphics execution file.
Example: C:orawingraph25mychart.ogr
Specify the full path if the Graphics and Forms files are NOT
located on FORMS45_PATH.
Commmode Specify ASYCHRONOUS or SYNCHRONOUS for the command mode.
To invoke Graphics, use SYNCHRONOUS mode.
1. SYNCHRONOUS returns control to Oracle Forms after you exit
the called product. You cannot work on form during the
execution of RUN_PRODUCT.
2. ASYCHRONOUS returns control to Oracle Forms immediately.
Calling Graphics is transparent to the user.
Execmode Specify BATCH or RUNTIME for execution mode.
To call Graphics, use BATCH mode (see bug 238279).
To call Forms, use RUNTIME mode.
Location Specify the location of the saved Graphics file.
Valid values are FILESYSTEM and DATABASE.
List Specify the parameter list to be passed to Graphics.
Display Specify the name of the Oracle Forms chart item that displays
the Oracle Graphics chart.
Create a Chart in Oracle Graphics Designer
------------------------------------------
1. Start the Oracle Graphics Designer.
2. Choose File-->Connect to connect to database.
3. Go to the Graphics Layout Editor.
4. Choose Window-->2. Graphics: Disp1: Layout Editor
5. Click on the CHART icon in the Tools Palette.
6. Click anywhere in the Layout Editor, drag the mouse, and draw a box
to create a chart.
7. When you release the mouse, a Chart Genie-New Query window displays with
Query and Data tabs.
8. On the Query tab, do the following:
a. Keep the default values of the Name, Type, and File fields.
b. Click on the SQL Statement display area.
c. Enter the SQL Query:
SELECT *
FROM dept;
d. Click on the Execute button to execute the query.
9. Click on the Data tab to see the data.
o Click on the OK button to bring up the Chart Properties.
10. On the Chart tab, do the following:
a. Enter the following:
Name: Dept_chart
Title: Sample Chart
b. For Type, click on the Column Chart icon.
11. Click on the Categories tab.
a. Select DNAME from Query Columns then click on the Insert button
to insert into Chart Categories (X axis).
b. Select DEPTNO from Chart Categories then click on the Delete button
to delete from X axis.
12. Click on the Values tab.
a. Select DEPTNO from Query Columns then click on the Insert button
to insert into Chart Values (Y axis).
b. Click the OK button to display the chart in the Layout Editor.
The chart shows the relationship of Department Id to Department Name
based on the dept table.
13. Select File-->Save to save the chart.
a. Enter mychart.ogd as File name.
b. Click the OK button.
14. Select File-->Administration-->Generate to generate the mychart.ogr file.
15. Select File-->Run to run the chart.
Create a Form That Uses RUN_PRODUCT to Bring Up mychart From Graphics
---------------------------------------------------------------------
1. Start the Oracle Forms Designer.
2. Select File-->Connect to connect to database.
3. In the Object Navigator, select Canvas-Views.
4. Click on the CREATE icon in the Tools Palette to create a canvas-view.
This creates a default block and button in the Object Navigator.
5. Double-click on CANVAS1 to bring up Layout Editor.
6. Click on the BUTTON icon in the Tools Palette.
7. Click anywhere on the Layout Editor, and drag the mouse to create a button.
8. Click on the CHART icon from the Tools Palette.
9. Click on the Layout Editor, and drag the mouse to create the chart area.
This creates a chart area in the Object Navigator.
11. Expand the PUSH_BUTTON item, and click on the Triggers node.
12. Click on the CREATE icon from Tools Palette.
13. Select the WHEN_BUTTON_PRESSED trigger, and click the OK button to
bring up PL/SQL Editor.
14. Enter the following command in the PL/SQL Editor to call Oracle Graphics:
RUN_PRODUCT(GRAPHICS, 'C:path_of_graphic_filemychart.ogr', SYNCHRONOUS,
BATCH, FILESYSTEM, NULL, 'block.CHART_AREA');
15. Click on the Compile button to compile the PL/SQL code.
16. Click on the Close button to exit the PL/SQL Editor.
17. Choose File-->Save to save the form.
a. Enter runprod.fmb as File name.
b. Click the OK button.
18. Choose File-->Administration-->Generate to generate the form.
19. Select File-->Run to run the form.
20. In Runform, click on the button to invoke the RUN_PRODUCT command.
A display of mychart appears the form's CHART_AREA.
21. Select File-->Exit to exit Runform.
Common Questions
----------------
1. Why does RUNTIME mode not return the chart to the form's CHART_AREA?
Why does it display Forms Runtime and Graphics Runtime screens?
This is a Bug 238279.
Workaround: Use BATCH execution mode to return the chart to the form's
CHART_AREA immediately.
2. When you execute the RUN_PRODUCT command, why does the following error
occur?
cannot open file 'c:pathgraphics.ogr'
RUN_PRODUCT cannot find the Oracle Graphics file on FORMS45_PATH.
3. Where do you set the FORMS45_PATH environment variable?
Windows: Set FORMS45_PATH in the C:WINDOWSORACLE.INI file.
Use any text editor to open the ORACLE.INI file.
Make sure you specify directory path in the
FORMS45_PATH section.
Windows 95: Set FORMS45_PATH using the Windows 95 Registry Editor.
Click on Start-->Run
Open REGEDIT.EXE to bring up the Windows 95 Registry Editor.
Click on HKEY_LOCAL_MACHINE
Click on SOFTWARE
Click on ORACLE
Look for the FORMS45_PATH variable settings.
Windows NT: Set FORMS45_PATH using the Windows NT Registry Editor.
Click on File-->Run
Open REGEDT32.EXE to bring up the Windows NT Registry Editor.
Click on HKEY_LOCAL_MACHINE
Click on SOFTWARE
Click on ORACLE
Look for the FORMS45_PATH variable settings.
And some more tips:
Doc ID: Note:14589.1
Subject: EMBEDDING A GRAPH IN FORMS V4
Type: FAQ
Status: UNDER_REVIEW
Content Type: TEXT/PLAIN
Creation Date: 29-JUL-1994
Last Revision Date: 10-MAY-2000
RTSS Bulletin Board Document
Doc #: 103381.882 Category: SQL*FORMS
Date: 25-AUG-93 Author: MMURUGAN
Abstract: (V4) EMBEDDING A GRAPH IN FORMS V4
(V4) Product Integration: Embedding A Graph In Forms V4 Oracle*Forms 4
Murali Murugan Tools Group
April 25, 1993 #103381.882
This bulletin tries to address two levels of integration between Oracle Forms
and Oracle Graphics:
1. Passing parameters from the calling application(Forms) to the called
application(Graphics).
2. Passing data records from the calling application(Forms) to the called
application(Graphics). This reduces the need for the called product to
query records from the database.
An Oracle Graphics application can be invoked from within Oracle Forms. But,
once a chart is invoked the user cannot make changes, such as scaling,
rotation, or color chart definition.
The objective is to query a record in Forms and see the corresponding data in
Graphics. Say, we have a form based on the DEPT block . In addition to the
fields from the DEPT table the form also has a chart item to display the chart.
The user queries up a department record and wants to see the salary for
each employee in the department in form of a chart. To accomplish this
we need to do the following:
Graphics Component
------------------
First, define a parameter DEPARTMENTNO of type NUMBER in the parameter table.
Next, create a query 'empquery' as:
SELECT empno, sal
FROM emp
WHERE deptno = :DEPARTMENTNO
ORDER BY sal
Lastly, create a procedure that queries the data and updates the chart:
PROCEDURE dispsalary
IS
the_query og_query;
the_chart og_object;
BEGIN
the_query := og_get_query('empquery'); /*get handle to query */
the_chart := og_get_object('empchart'); /* get handle to the chart object */
og_execute_query(the_query); /* execute the query */
og_update_chart(the_chart, OG_ALL_CHUPDA); /* update the chart */
END;
Associate the above procedure with the OPEN DISPLAY trigger, so that the
procedure is executed everytime the chart is opened.
Forms Component
---------------
Scenerio I: Passing parameter to Graphics to get an updated display in the
Chart Item in the form.
PROCEDURE pass_parameter
IS
plid paramlist;
the_param varchar2(15) := 'tmpdata';
BEGIN
plid := get_parameter_list(the_param); /* check if 'tmpdata' exists */
IF NOT id_null(plid) THEN
destroy_parameter_list(plid); /* if it does destroy it */
END IF;
plid := create_parameter_list(the_param); /* create it afresh */
/* associate the parameter in the form with the parameter in the chart */
add_parameter(plid, 'departmentno', TEXT_PARAMETER, to_char(:dept.deptno));
run_product(GRAPHICS, /* product name */
'formgraph.ogd', /* Graphics document */
SYNCHRONOUS, /* communication mode */
BATCH, /* execution mode */
FILESYSTEM, /* location of the Graphics document */
plid, /* handle to the parameter list */
'dept.showchart' /* name of the Chart Item in Forms */
);
END;
Scenerio II: Passing data from a record group to replace the query defined
in Graphics.
PROCEDURE pass_record
IS
graphquery varchar2(15) := 'empquery'; /* name of the graphics query */
queryrec varchar2(15) := 'recgroup'; /* name of the record group */
the_param varchar2(15) := 'tmpdata';
plid paramlist;
rgid recordgroup;
the_query varchar2(1000); /* store query in this */
return_cd number;
BEGIN
/* create the query string */
the_query := 'SELECT empno, sal FROM emp WHERE deptno='||
to_char(:dept.deptno)||' ORDER BY sal';
rgid := find_group(queryrec); /* get handle to record group */
IF id_null(rgid) THEN
rgid := create_group_from_query(queryrec, the_query);
/* creating group from query,
if it wasn't found */
END IF;
delete_group_row(rgid,all_rows); /* empty the record group */
return_cd := populate_group_with_query(rgid,the_query);
/* populate record group using the defined query */
plid := get_parameter_list(the_param); /* check if 'tmpdata' exists */
IF NOT id_null(plid) THEN
destroy_parameter_list(plid); /* if yes - destroy it */
END IF;
plid := create_parameter_list(the_param); /* create it afresh */
/* associate the record group
with the query in Graphics */
add_parameter(plid, graphquery, DATA_PARAMETER, queryrec);
run_product(GRAPHICS, /* product name */
'formgraph.ogd', /* Graphics document */
SYNCHRONOUS, /* communication mode */
BATCH, /* execution mode */
FILESYSTEM, /* location of the Graphics document */
plid, /* handle to the parameter list */
'dept.showchart' /* name of the Chart Item in Forms */
);
END;
Associate the appropriate procedure with the POST-QUERY trigger to achieve the
objective defined at the top of this bulletin.
.
--------------------------------------------------------------------------------
Copyright (c) 1995,2000 Oracle Corporation. All Rights Reserved. Legal Notices and Terms of Use.
**************************************************************************************************
Document ID: 9886299.61
Title: How To Pass A Record Group From Forms To Graphics
Creation Date: 20 December 1995
Last Revision Date: 15 January 1997
Revision Number: 2
Product: ORACLE GRAPHICS/ORACLE FORMS
Product Version: V2.5/V4.5
Platform: GENERIC
Information Type: INQUIRY
Impact: MEDIUM
Abstract: This document provides an example of how to construct
a record group based upon a value in a Forms block
and pass it to Graphics.
Keywords: RECORD;GROUP;FORMS;GRAPHICS;EMBED;CHART;UPDATE;DEVELOPER/2000
________________________________________________________________________________________
How To Pass A Record Group From Forms To Graphics
=================================================
Introduction
------------
One common motivation for embedding an Oracle Graphics chart within an
Oracle Forms module is to have the chart dynamically reflect data
within the form block. By doing this, the user can view a graphical
representation of the current form data. The following provides a
practical example of how this can be done. Both the chart and the
form are based upon the scott.emp table which is commonly available on
most installed Oracle databases.
Implementation
--------------
1. Create a default 'scott.emp' block containing, for clarity's sake,
just two items, 'emp.sal' and 'emp.deptno'.
2. Create another block -- here called "chart_block" -- which
contains the chart object.
3. Create a chart (the_display.ogd) in Graphics. This is a simple bar
chart based upon the following query:
SELECT deptno, SUM(sal) sumsal
FROM emp
GROUP BY deptno
4. Within Forms, place the following line in a When-New-Form-Instance trigger:
OG.OPEN('orawingraph25the_display.ogd', 'chart_area3',FALSE, TRUE);
This routine -- contained within the 'og.pll' library which needs to
be attached to the Form module -- will embed the chart object within
the Form's chart area. Please refer to the "Forms Advanced
Techniques" document for more detailed info regarding the 'OG' library
routines.
5. Now, to the heart of the matter, a Forms procedure called
'pass_data' actually builds a record group based upon the current
Forms record and passes it to Graphics as a parameter with the
intention of updating the chart to reflect the current Forms record:
PROCEDURE pass_data IS
val VARCHAR2(50) := 'chart_data_rg';
pl_id PARAMLIST;
rg RECORDGROUP;
qry VARCHAR2(2000);
stat NUMBER;
BEGIN
/* Close the current display to be able to start anew */
OG.CLOSE('orawingraph25the_display.ogd', 'chart_area3');
/* Create the query using the value of ':emp.deptno' */
qry := 'SELECT deptno, sum(sal) sumsal FROM emp WHERE deptno = :emp.deptno
GROUP BY deptno';
rg := FIND_GROUP('chart_data_rg');
/* If the record group called 'chart_data_rg' does not exist, create it */
IF ID_NULL(rg) THEN
rg := CREATE_GROUP_FROM_QUERY('chart_data_rg', qry);
END IF;
/* Remove any data that might already be in an existing record group
** and re-populate it */
DELETE_GROUP_ROW(rg, ALL_ROWS);
stat := POPULATE_GROUP_WITH_QUERY(rg, qry);
/* Check if a parameter list already exists before creating one
** If one already exists, delete it before creating a new list */
pl_id := GET_PARAMETER_LIST('the_parameter_list');
IF NOT ID_NULL(pl_id) THEN
DESTROY_PARAMETER_LIST('the_parameter_list');
END IF;
/* Create the parameter list without fear of duplication error */
pl_id := CREATE_PARAMETER_LIST('the_parameter_list');
/* The call below is critical in the sense that the second argument -- the
** name of the parameter -- **must** match the name of the query upon
** which the chart is based in order for the record group to be substituted
** for the query used to build the original chart. Note also that the
** third argument -- the parameter type -- must be DATA_PARAMETER in order
** for the specified record group to substitute for the query that Oracle
** Graphics would ordinarily execute to run the display */
ADD_PARAMETER(pl_id, 'query0', DATA_PARAMETER, val);
/* Reopen the display while passing the record group parameter
** list to Oracle Graphics, which will substitute for the query that
** would ordinarily be run to build the chart */
OG.OPEN('orawingraph25the_display.ogd', 'chart_area3',FALSE,TRUE,pl_id);
/* For good measure, destroy the parameter list that was just created */
DESTROY_PARAMETER_LIST(pl_id);
END;
------------------------END PROCEDURE pass_data--------------------------------
6. Create a When-Mouse-Click trigger attached to the chart object so
that the user has only to click on the chart to update it. Another
alternative is to place 'pass_data' in a When-New-Record-Instance on
the 'emp' block so that the chart is updated as input focus moves from
record to record in the block.
7. Finally, a good programming practice is to use a Post-Form trigger
to terminate Forms' connection to the graph:
OG.CLOSE('orawingraph25ddgraph.ogd', 'chart_area3');
Additional Information
----------------------
For an alternate method of passing record groups from Oracle Forms 4.5 to
Oracle Graphics 2.5, refer to Oracle Support Bulletin #9246291.61.
Note: This bulletin has been verified on Windows NT 4.0 Developer/2000 Rel 1.3.2
---------------------------------------------------------------------------------
Oracle WorldWide Customer Support
**************************************************************************************
Doc ID: Note:1010433.6
Subject: HOW TO PASS PARAMETER FROM FORMS TO GRAPHICS
Type: PROBLEM
Status: REVIEWED
Content Type: TEXT/PLAIN
Creation Date: 16-JUN-1995
Last Revision Date: 12-MAY-2001
@DO NOT DELETE the following Disclaimer>
*************************************************************
This article is being delivered in Draft form and may contain
errors. Please use the MetaLink "Feedback" button to advise
Oracle of any issues related to this article.
*************************************************************
Problem Description:
====================
How do you pass text or data parameters from Oracle Forms to Oracle Graphics?
In Oracle Forms, you try to pass parameters to populate a chart item that
displays an Oracle Graphics chart, but the chart does not update.
Solution Description:
=====================
1. You can pass a parameter list that include text and/or data parameters
from Oracle Forms 4.5 to Oracle Graphics 2.5 whenever your application
executes any of the following procedures:
RUN_PRODUCT
OG.OPEN
OG.INTERPRET
OG.MOUSEDOWN
OG.MOUSEUP
Use the following syntax:
RUN_PRODUCT(product,document,commmode,execmode,location,plist,
display);
OG.OPEN(display,item,clip,refresh,plist);
OG.INTERPRET(display,item,pls_string,refresh,plist);
OG.MOUSEDOWN(display,item,x,y,refresh,clickcount,button,constrained,
plist);
OG.MOUSEUP(display,item,x,y,refresh,button,constrained,plist);
To call subprograms defined in the OG package, you need to attach the
OG.PLL library to your form.
NOTE:
Do not use OG.REFRESH to pass parameters.
This is documentation bug 325542, which is fixed in
Oracle Graphics 3.0.2. The use of OG.REFRESH in the following
documentation is incorrect:
Oracle Forms 4.5 Advanced Techniques Manual
Chapter 8, Integrating with Other CDE Tools
USING CHART ITEMS TO EMBED ORACLE GRAPHICS DISPLAYS
Passing Parameters and Data to Oracle Graphics
The "Passing a Text Parameter" and "Passing a Data Parameter" examples
contain errors. Change the OG.REFRESH line of code to the following line:
OG.OPEN('sal_chart.ogd', 'dept.chart_item', FALSE, TRUE, pl);
In general, avoid using OG.REFRESH. It is a confusing procedure and
used in rare situations.
2. Create a dummy query that matches the record group in
column names, column data types, and the number of columns.
Example
-------
SELECT 1 empno, 1 sal
FROM dual;
3. When you create the record group query, use aliases,
so the column names match the column names in the chart.
Example
-------
SELECT deptno ename, deptno*3 sal
FROM dept;
4. Kill OGBATCH before running this code OR
make sure you have already not opened a chart in the
current OGBATCH session.
Always kill OGBATCH when you open a chart a second time.
If this is too restrictive, use OG.INTERPRET after the initial OG.OPEN.
Additional Information:
=======================
Oracle Documentation:
---------------------
Oracle Forms 4.5 Reference Manual
Chapter 3, Built-in Subprograms
RUN_PRODUCT
Oracle Forms 4.5 Advanced Techniques Manual
Chapter 8, Integrating with Other CDE Tools
USING CHART ITEMS TO EMBED ORACLE GRAPHICS DISPLAYS and THE OG PACKAGE
Related Bugs:
-------------
[[BUG:325542]] OG.REFRESH NOT WORKING OR UPDATING THE GRAPH (TRIAGE1295)
Solution: PASSING PARAMETERS AND DATA TO ORACLE GRAPHICS; BUL 103381.882
Solution Description:
=====================
There are the two ways to pass parameters when populating a chart item with
an Oracle Graphics display:
o Pass a text parameter
The form passes Oracle Graphics a parameter with a value for the parameter
that was defined in the display; Oracle Graphics then uses that value to
execute the query, builds the dispaly, and passes it to the form chart item.
o Pass a data parameter
The form programmatically creates and populates a query record group, then
passes the resulting record set to Oracle Graphics as a data parameter. The
data queried by the form satisfies the named query defined in the display.
Oracle Graphics uses the data to build the display (without querying the
database), then populates the form chart item.
For sample code, see:
Bulletin 103381.882
OR
USING CHART ITEMS: Passing Parameters and Data
in chapter 23, "Integrating with Other Products",
of the Oracle Forms User's Guide, Version 4.0.
OR
USING CHART ITEMS TO EMBED ORACLE GRAPHICS DISPLAYS:
Passing Parameters and Data to Oracle Graphics
in chapter 8, "Integrating with Other CDE Tools",
of the Oracle Forms 4.5 Advanced Techniques Manual.
For information regarding text parameters and data parameters, see:
PASSING PARAMETERS TO CALLED PRODUCTS
in chapter 23, "Integrating with Other Products",
of the Oracle Forms User's Guide, Version 4.0.
OR
PASSING PARAMETERS TO CALLED PRODUCTS
in chapter 8, "Integrating with Other CDE Tools",
of the Oracle Forms 4.5 Advanced Techniques Manual.
Solution Explanation:
=====================
Refer to:
BUL 103381.882 (V4) EMBEDDING A GRAPH IN FORMS V4
|
|
|
Re: Calling a chart from a report [message #111497 is a reply to message #88282] |
Wed, 16 March 2005 17:05 |
Matloob
Messages: 39 Registered: December 2004
|
Member |
|
|
HI,
NICE HELP MAN
I HAVE SOME PROBLEM WITH THAT
WHEN I RUN THE CODE IN RUNTIME IT RUNS PERFECT BUT IT OPENS A NEW WINDOW THEN I TRY TO RUN IN BATCH MODE I USE THESE COMANDS:
1. METHORD
------------------------------------------------------------
RUN_PRODUCT (GRAPHICS,'D:\Documents and Settings\Developer\Desktop\Disp2.ogr',SYNCHRONOUS,BATCH,
FILESYSTEM,NULL,'block7.CHART_AREA');
ERROR:
1. TOO MANY DECLARATIONS OF 'RUN_PRODUCT' MATCH THIS CALL
2. STATMENT IGNORED
-------------------------------------------------------------
2. METHORD
------------------------------------------------------------
RUN_PRODUCT (GRAPHICS,'D:\Documents and Settings\Developer\Desktop\Disp2.ogr',SYNCHRONOUS,BATCH,
FILESYSTEM,'block7.CHART_AREA');
ERROR:
THERE IS NO ERROR WHILE COMPILATION BUT WEHN I RUN THE FORM IT DOES NOT LOAD THE CHART IM THE CHART DISPLAY AREA IT SHOWS THE BLACNK SCREEN
-------------------------------------------------------------
PLZ DO PROVIDE ME THE SUGESTION OR SEND ME SAMPLE CODE ON
matloob84@gmail.com
thanks
|
|
|
|
Re: Calling a chart from a report [message #173823 is a reply to message #88274] |
Wed, 24 May 2006 11:52 |
rita_carvalho
Messages: 2 Registered: May 2006
|
Junior Member |
|
|
Hi!
I need some help in this section...
Can someone helps me??
So i have a question...
i want to update a chart in a form... it is possible doing that without using the OG package and removing the checkbox from the chart porperties->data tab->query execution???
I run a chart from a form with the instruction RUN_PRODUCT(GRAPHICS, 'C:path_of_graphic_filemychart.ogr', SYNCHRONOUS,
BATCH, FILESYSTEM, NULL, 'block.CHART_AREA'), because i don't have the OG package.
I want to do this because if i run the form and the grafhics on the web the label's on the grachics stay like charts_web_BAD.JPG and i want the labels like in the charts_form_GOOD.JPG (that i'll send in another post!!!!)
thank you!!!
RIta
|
|
|
|
Goto Forum:
Current Time: Fri Nov 29 21:18:08 CST 2024
|