0941-0944

Previous Table of Contents Next

Page 941

form button with a WHEN-BUTTON-PRESSED trigger. First create a new button on the form canvas labeled Print Document and then create the trigger as

 declare         plist        ParamList;      begin         plist := create_parameter_list (`print_parms');         add_parameter (plist, `P-order_no', TEXT_PARAMETER,                                                    to_char (:orders.order_no)); add_parameter (plist, `PARAMFORM, TEXT_PARAMETER, `NO');         add_parameter (plist, `DESTYPE', TEXT_PARAMETER, `PRINTER');         add_parameter (plist, `BATCH', TEXT_PARAMETER, `YES');         RUN_PRODUCT (REPORTS, `r39oun01.rdf', ASYNCHRONOUS, BATCH,                                                FILESYSTEM, plist);         destroy_parameter_list (plist);      end; 

As indicated by this module, the command-line parameters for the R25RUN command are passed to the product as part of the parameter list. This is all that is needed to run a report directly to the printer from Oracle Forms. Also, note that the report will be run asynchronously in the background, while the operator is free to execute other tasks as the report is printing. You can also use the RUN_PRODUCT built-in to invoke Oracle Graphics from Oracle Forms; however, the Graphics chart will not have the same interactive functionality as shown in the previous section.

Displaying Oracle Graphics in Oracle Reports

You can add Oracle Graphics to a report by using the Oracle Graphics tool in the report's Layout Editor. To demonstrate this concept, open the first report created in Chapter 37, "Oracle Graphics." You will add the warehouse pie chart to the report, to be displayed below the numerical data.

Select the Oracle Graphics tool from the tool palette, and drag an area for the chart below the main report layout. The new object displays a chart in the designated area. Double-click in this area to display the chart definition dialog as shown in Figure 38.2. Name this object D_performance, and define the Graphics file as g39oun01.ogd. Run the report and save the new report in a file.

Figure 38.2.
Oracle Graphics chart definition dialog.


Page 942

Interfacing to Non-Oracle Applications

Oracle Forms 4.5 provides the capability to interface with non-Oracle applications, such as Microsoft Excel or Microsoft Word, using OLE2 protocol as defined by Microsoft Corporation. For example, the Customer Credit Maintenance Form shown in Figure 38.3 includes an Excel spreadsheet embedded directly as part of the form. Whenever a user double-clicks the spreadsheet box, the complete functionality of Microsoft Excel is included in the form.

Figure 38.3.
Integrating an OLE application into Oracle Forms.


To construct this form module, first build the CUSTOMERS block as shown displaying the customer number, name, and the credit information fields. Now, select the OLE2 tool from the palette in the Layout Editor. Drag an area on the canvas that will hold the OLE container. (When the tool is activated, the actual area for the tool appears larger to accommodate the row and column headers, as well as the scrollbar information.)

Select the property sheet for the OLE object, and modify the properties as indicated in Table 38.1.

Table 38.1. OLE object properties.

Property
Value
OLE In-Place Activation True
OLE Activation Style Double-click
OLE Resize Style Scale

Page 943

Property
Value
OLE Tenant Types Embedded
Show Do In Out True
OLE Tenant Aspect Content

Select the OLE object in the Layout Editor and click the right mouse button to display the OLE object menu. Select Insert Object from the menu to display the dialog shown in Figure 38.4. Select Excel Worksheet and click OK. (The Display as Icon checkbox causes the item to display as an Excel icon until it is activated.) At this point, the Excel spreadsheet is embedded into the form module. To initialize the spreadsheet, select the edit spreadsheet function from the OLE object menu (right mouse button) and create the initial spreadsheet. For more information, see your Excel documentation to understand the functions of this tool.

Figure 38.4.
OLE object type definition dialog box.


You can use these techniques to embed an OLE-compliant application in an Oracle Forms module. Alternatively, instead of embedding an application in the form, you can use OLE linking. OLE linking causes the form module to link directly to an existing OLE-compliant file, such as any .XLS Excel spreadsheet. To link the file, the only differences are that you define the OLE Tenant Types property to Linked and you select the existing file from the Insert Object menu.

Page 944

NOTE
Linking files in Oracle Forms requires a lot of resources on the client computer. Make sure that only necessary applications are running on a machine that has been maximized with RAM. Without a powerful machine, object linking results in frequent General Protection Faults.

Interfacing with the Windows API and
Other DLLs

Oracle Forms also allows the user to interface to subprograms or routines that are written in a third-generation programming language such as C or COBOL. You must load these functions into a dynamic library, such as a .DLL file in Microsoft Windows, or a shared library in UNIX systems. These functions can be Oracle precompiler foreign functions or non-Oracle functions. The method for using either type of function is the same.

To use a foreign function, you must load the dynamic library using the ORA_FFI.LOAD_LIBRARY procedure:

 fh_mylib := ora_ffi.load_library (path, filename); 

After the library is loaded, you must register the function in FORMS (example is shown for a C subprogram module):

 fh_func := ora_ffi.register_function (fh_mylib, function_name, ora_ffi.C_STD); 

The next step is to register the parameters for the module in the order in which they appear in the function definition (as shown below for a C integer value):

 ora_ffi.register_parameter (fh_func, ORA_FFI.C_INT); 

Finally, the last step needed to register the function is to define the return value type for the function:

 ora_ffi.register_return (fh_func, ORA_FFI.C_INT); 

You then create the PL/SQL interface to this function as follows :

 FUNCTION ff_pls_equiv_my_func (ff_handle ORA_FFI.FUNCHANDLETYPE,                                                        parm1 IN BINARY_INTEGER,                                                        parm2 IN BINARY_INTEGER) RETURN BINARY_INTEGER is         PRAGMA interface (C, ff_pls_equiv_my_func, 11265);      BEGIN                  ...      END; 

You can then call the foreign function directly using PL/SQL in parameters to return a value.

Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net