Oracle COM Automation Feature Developer's Guide Release 9.2 Part Number A95499-01 |
|
This chapter describes how to use Oracle COM Automation Feature demonstration programs for PL/SQL.
This chapter contains these topics:
Oracle COM Automation Feature for PL/SQL includes examples that demonstrate how to use the feature to build solutions. These demos provide base functionality and can serve as a foundation on which to build more customized, complex applications that use COM Automation. The demos are based on the human resources schema available with the sample schema.
Each demo exposes a core set of APIs that enables you to do simple operations using COM Automation. Each COM Automation server, such as Word and Excel, provides more advanced capabilities than what is offered through the demo APIs. To take advantage of these advanced features, you must design and code your own PL/SQL procedures.
In this release, Oracle Corporation has provided the following demos:
The following sections describe how to install the Microsoft Word demo and the APIs that it exposes. This demo is provided as an example of the types of solutions that can be built with Oracle and Microsoft Word.
The demo creates a Microsoft Word document containing the names of employees in the database.
The Microsoft Word demo provides the following:
ORDWord
, a PL/SQL package that exposes several APIs for manipulating Microsoft Word. This package is created by the wordsol.sql
script.worddem.sql
, a script that displays the capabilities of exchanging data between Oracle and Microsoft Word. It exchanges data from the EMPLOYEES
and JOBS
tables to a Microsoft Word document. These tables are available in the human resources schema in the sample schema.Microsoft Word must be installed on the local computer before installing this demo.
To install the Microsoft Word demos:
C:\> sqlplus /NOLOG
SQL> connect hr/hr
wordsol.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\wordsol.sql;
This script creates the ORDWord
package in the current user's schema. You receive the following error several times when you run this script for the first time:
ORA-04043: object XXXX does not exist.
These messages are normal.
To use the Microsoft Word demo:
worddem.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\worddem.sql;
This script creates a Microsoft Word document (worddemo.doc
) in the C:\
directory. The document contains data from the EMPLOYEES
and JOBS
tables. These tables are available in the human resources schema in the sample schema.
worddemo.doc
to see its contents.The following subsections describe the APIs that the Microsoft Word demo exposes. These APIs are primitive. Be aware that much of the functionality that Microsoft Word exposes through COM Automation is not exposed through these APIs.
Instantiates a Word.Basic
object in the Microsoft Word Automation server.
FUNCTION CreateWordObject() RETURN BINARY_INTEGER;
This function must be called before any other operation can be performed. This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Creates a new Microsoft Word document.
FUNCTION FileNew() RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Loads a document into Microsoft Word.
FUNCTION FileLoad(filename VARCHAR2) RETURN BINARY_INTEGER;
Where | Is |
---|---|
|
the fully qualified |
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Saves the current Microsoft Word document to disk.
FUNCTION FileSave() RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Saves the current Microsoft Word document as a specific file.
FUNCTION FileSaveAs(filename VARCHAR2) RETURN BINARY_INTEGER;
Where | Is |
---|---|
|
the fully qualified |
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Closes the current Microsoft Word document.
FUNCTION FileClose() RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Inserts a text string into the current Microsoft Word document.
FUNCTION InsertText(textstr VARCHAR2) RETURN BINARY_INTEGER;
Where | Is |
---|---|
|
the text that will be inserted into the document. |
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Inserts a carriage return into the current Microsoft Word document.
FUNCTION InsertNewLine() RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Sets the font size for the current Microsoft Word document.
FUNCTION FormatFontSize(fontsize BINARY_INTEGER) RETURN BINARY_INTEGER;
Where | Is |
---|---|
|
the point size of the font. |
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
The following sections detail how to install the Microsoft Excel demo and describe the APIs that it exposes. This demo is provided as an example of the types of solutions that can be built with Oracle and Microsoft Excel.
The Microsoft Word demo provides the following:
ORDExcel
, a PL/SQL package that exposes several APIs for manipulating Microsoft Excel. This package is created by the excelsol.sql
script.exceldem.sql
, a script that displays the capabilities of exchanging data between Oracle and Microsoft Word. It exchanges data from the EMPLOYEES
and JOBS
tables in Oracle to a Microsoft Excel spreadsheet and puts it in a graph. These tables are available in the human resources schema in the sample schema.Microsoft Excel must be installed on the local computer before installing this demo.
To install the Microsoft Excel demo:
C:\> sqlplus /NOLOG
SQL> connect hr/hr
excelsol.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\excelsol.sql;
This script creates the ORDExcel
package in the current user's schema. You receive the following error several times when you run this script for the first time:
ORA-04043: object XXXX does not exist.
These messages are normal.
To use the Microsoft Excel demo:
exceldem.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\exceldem.sql;
This script creates a Microsoft Excel spreadsheet (excel
xxxxx
.xls
) in the C:\
directory. The document contains data from the EMPLOYEES
and JOBS
tables. These tables are available in the human resources schema in the sample schema.
excel
xxxxx
.xls
file, where xxxxx
is a time stamp, to see its contents.The following subsections describe the APIs that the Microsoft Excel demo exposes. These APIs are primitive. Be aware that much of the functionality that Microsoft Excel exposes through COM Automation is not exposed through these APIs.
Starts the Microsoft Excel COM Automation server and instantiates the objects for a workbook and a worksheet.
FUNCTION CreateExcelWorkSheet() RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Inserts any kind of data into a specific cell of the current Excel worksheet.
FUNCTION InsertData(range VARCHAR2, data ANY PL/SQL DATATYPE, datatype VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Creates a chart of a specified range of data and inserts the chart at the x and y position of the current worksheet with the desired height and width.
FUNCTION InsertChart(xpos BINARY_INTEGER, ypos BINARY_INTEGER, width BINARY_ INTEGER, height BINARY_INTEGER, range VARCHAR2, type VARCHAR2) RETURN BINARY_ INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Saves the current Microsoft Excel workbook as a specific file.
FUNCTION SaveExcelFile(filename VARCHAR2) RETURN BINARY_INTEGER;
Where | Is |
---|---|
|
the fully qualified |
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Performs some cleanup and destroys the outstanding references to the Excel COM Automation server. This should be the last API called.
FUNCTION ExitExcel() RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
The following sections detail how to install the Microsoft PowerPoint demo and describe the APIs that it exposes. This demo is provided as an example of the types of solutions that can be built with Oracle and Microsoft PowerPoint.
The Microsoft PowerPoint demo provides the following:
ORDPPT
, a PL/SQL package that exposes several APIs for manipulating Microsoft PowerPoint. This package is created by the pptsol.sql
script.pptdem.sql
, a script that displays the capabilities of exchanging data between Oracle and Microsoft PowerPoint. It exchanges data from the EMPLOYEES
and JOBS
tables in Oracle to a Microsoft PowerPoint document. These tables are available in the human resources schema in the sample schema.Microsoft PowerPoint 97 or later must be installed on the local computer before installing this demo.
To install the Microsoft PowerPoint demo:
C:> sqlplus /NOLOG
SQL> connect hr/hr
pptsol.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\pptsol.sql;
This script creates the ORDPPT
package in the current user's schema. You receive the following error several times when you run this script for the first time:
ORA-04043: object XXXX does not exist.
These messages are normal.
To run the Microsoft PowerPoint demo:
pptdem.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\pptdem.sql;
This script creates a Microsoft PowerPoint presentation (pptdemo.ppt
) on C:\. The document contains a list of employee names.
pptdemo.ppt
to see its contents.The following subsections describe the APIs that the Microsoft PowerPoint demo exposes. These APIs are primitive. Be aware that much of the functionality that Microsoft PowerPoint exposes through COM Automation is not exposed through these APIs.
Starts the Microsoft PowerPoint COM Automation server and instantiates the objects for a presentation.
FUNCTION CreatePresentation (servername IN VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Inserts a new slide in the PowerPoint presentation.
FUNCTION AddSlide (layout IN BINARY_INTEGER) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Specifies the title of the PowerPoint slide.
FUNCTION SetTitle (title IN VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Inserts text into the specified location on the slide.
FUNCTION InsertText (orientation IN BINARY_INTEGER, left IN BINARY_INTEGER, top IN BINARY_INTEGER, width IN BINARY_INTEGER, height IN BINARY_INTEGER, text IN VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Saves the current PowerPoint presentation.
FUNCTION PresentationSave RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Saves the current presentation using the specified name.
FUNCTION PresentationSaveAs (filename IN VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Closes the current PowerPoint presentation.
FUNCTION PresentationClose RETURN binary_integer;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Exits the PowerPoint program.
FUNCTION Exit RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
The following sections detail how to install the Messaging Application Programming Interface (MAPI) demo and describe the APIs that it exposes. This demo is provided as an example of the types of solutions that can be built with Oracle and MAPI-compliant applications.
The MAPI demo provides the following:
ORDMAPI
, a PL/SQL package that exposes several APIs for manipulating Extended MAPI client.mapidem.sql
, a script that displays the capabilities of exchanging data between Oracle and Extended MAPI client.You must set up certain related applications in order to use the MAPI demo.
To set up the environment for the MAPI demo:
Start > Programs > Microsoft Exchange > Active Directory Users and Computers.
Select your domain and expand the folders. Select users, then right-click to create a new user.
Select custom install. Select the Collaboration Data Objects (these are not installed by default).
During the install, select the Corporate or Workgroup option.
Add the account you created on Exchange Server.
Enter your incoming and outgoing mail servers, and enter the account name and password.
Select the connection type (for example, LAN).
From Internet Explorer, choose the Tools menu > Internet Options > Programs and set the fields.
The MAPI Solution invokes Extended MAPI client on the behalf of the Oracle database server. The Oracle database service on Windows NT, by default, runs as NT system user LocalSystem
. The MAPI profile for user LocalSystem
is not easily configured. Before using the MAPI Solution, change both the Windows NT Oracle database service and Oracle
HOME_NAMETNSListener
service to start up using a Windows NT login user account.
To prepare to install the MAPI demo:
DOMAIN-1\hr
.DOMAIN-1\hr
. Make sure that you are able to send out e-mail using this profile.Oracle
HOME_NAMETNS
Listener
service.Oracle
HOME_NAMETNS
Listener
service and click Startup.DOMAIN-1\hr
.DOMAIN-1\hr
.Oracle
HOME_NAMETNS
Listener
service.DOMAIN-1\hr
.DOMAIN-1\hr
.The MAPI application, such as Microsoft Outlook 2000 or later, must be installed on the local computer before installing this demo.
To install the MAPI demo:
C:> sqlplus /NOLOG
SQL> connect hr/hr
mapisol.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\mapisol.sql;
This script creates the ORDMAPI
package in the current user's schema. You receive the following error several times when you run this script for the first time:
ORA-04043: object XXXX does not exist.
These messages are normal.
To use the MAPI demo:
mapidem.sql
with a text editor and change the e-mail address hr@us.oracle.com
in ORDMapi.AddRecipient
to your own e-mail address. Save the change.mapidem.sql
script at the SQL*Plus prompt:SQL> @ORACLE_BASE\ORACLE_HOME\com\demos\mapidem.sql;
This script connects to a database server, extracts the data, and sends an e-mail to a specified recipient.
The following subsections describe the APIs that the MAPI demo exposes. These APIs are primitive. Be aware that much of the functionality that MAPI exposes through COM Automation is not exposed through these APIs.
Starts the MAPI COM Automation server and instantiates the objects for a session.
FUNCTION CreateMAPISession (servername IN VARCHAR2 DEFAULT '', profilename IN VARCHAR2 DEFAULT NULL, password IN VARCHAR2 DEFAULT NULL) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Creates a new message.
FUNCTION NewMessage RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Adds the e-mail address of a recipient. This is the address where the e-mail message will be sent.
FUNCTION AddRecipient (emailaddress VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Specifies the subject of the e-mail message.
FUNCTION SetSubject (subject VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Inserts the body text of the e-mail message.
FUNCTION SetBody (messagetext VARCHAR2) RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Sends the e-mail message to the specified recipients.
FUNCTION SendMessage RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
Exits the MAPI session.
FUNCTION EndMAPISession RETURN BINARY_INTEGER;
This procedure returns a 0
when successful or a nonzero HRESULT
when an error occurs.
|
Copyright © 1999, 2002 Oracle Corporation. All Rights Reserved. |
|