PK
    AAoa,         mimetypeapplication/epub+zipPK  AA               iTunesMetadata.plistj

This appendix contains these topics:
The following is a list of Oracle COM Automation Feature PL/SQL errors and their common causes.
CreateObject as well as COM objects obtained as property values and return values.pexcepinfo should be filled in GetLastError to get this additional informationInvoke tried to set the value of a read-only property.The following is a list of Microsoft COM Automation errors and their common causes. Both the hexadecimal and binary error codes are listed.
NULL value was passed as a method parameter.NULL.This chapter describes aspects of the programming interface for Oracle COM Automation Feature.
This chapter contains these topics:
Because Microsoft COM Automation uses COM Automation data types, and Oracle COM Automation Feature uses either PL/SQL or Java data types, Oracle COM Automation Feature must convert the data that it receives and pass it to the COM Automation object. Similarly, Oracle COM Automation Feature must pass the data that it receives from the COM Automation object and convert it.
Table 3-1 shows the mapping between PL/SQL data types and COM Automation data types.
This guide follows a convention where COM Automation data types are prefaced by an initial p when used as IN OUT or OUT parameters. Data types without the initial p are IN parameters.
Table 3-1 PL/SQL to COM Automation Data Types
| PL/SQL Data Type | COM Automation Data Type | 
|---|---|
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| Note:Oracle restricts a CYandpCYvalue to be between -9999999999.9999 and 9999999999.9999. | 
Table 3-2 lists the supported COM Automation data types and related mappings to Java data types.
All data type mapping applies to properties, arguments, and return values, except void, which applies only to return values.
Table 3-2 Java to COM Automation Data Types
| Java Data Type | COM Automation Data Type | 
|---|---|
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
HRESULT error codes are provided by the Microsoft Windows API.
An HRESULT is a COM error code of the hexadecimal form 0x800nnnnn. However, it has the decimal form -214nnnnnnn. For example, passing an invalid object name when creating a COM object causes the HRESULT of -2147221005 to be returned, which is 0x800401f3 in hexadecimal form.
For complete information about the HRESULT return code, refer to the Microsoft documentation.
The PL/SQL APIs return an integer return code. The return code is 0 when successful, or a nonzero value of HRESULT when an error occurs.
| See Also:"GetLastError" for additional information about how to interpret the return codes from Oracle COM Automation Feature | 
Oracle COM Automation for Java uses standard Java exception mechanisms. Specifically, a Java exception class, oracle.win.com.COMException, is introduced to represent COM errors.
This exception is thrown by the Automation Java class when an error occurs.
The error information provided by this exception is similar to that provided by the PL/SQL API GetLastError function.
| Note:The HRESULTdata member has the same meaning as the value ofHRESULTreturned by the PL/SQL functions. | 
If the COM error is DISP_E_EXCEPTION as indicated by the excepInfo data member, COMException uses the source, description, helpfile, and helpid data members. Otherwise, these data members are not valid.
The COMException writes an error message representing the COM error to the errmsg data member.
Table 3-3 lists the COMException data members and their descriptions.
Table 3-3 COMException Data Members
| Member | Description | 
|---|---|
| 
 | is an  | 
| 
 | is the textual representation of  | 
| 
 | is the  | 
| 
 | is the error description. | 
| 
 | is the fully qualified path name of the  | 
| 
 | is the help context ID of a topic within the  | 
| 
 | is  | 
Code Sample
This example demonstrates the COMException exception.
 try
   {
     // Some code that might throw a COMException exception.
   }
   catch(COMException e)
   {
     System.out.println(e.toString());
     if(e.excepInfo)
     {
       System.out.println(e.source);
       System.out.println(e.description);
       System.out.println(e.helpfile);
       System.out.println(e.helpid);
     }
   }
This section discusses the required information and the general steps to build a solution using Oracle COM Automation Feature.
Review the following information about the COM objects that you intend to use:
You must determine the Program ID of the COM object. The Program ID, or progID, is a descriptive string that maps to the globally unique identifier (GUID), a hexadecimal number that uniquely identifies a COM object.
The following string is an example of a progID:
Excel.Worksheet.1
Use the progID with the API that instantiates the COM object.
You must be aware of the types of properties and methods that are exposed through the COM object's IDispatch interface. Usually, the ISV provides documentation describing the names and data type of the object's properties and the prototypes of the object's methods. Properties are referred to by a descriptive string, such as xpos or ypos. A property can be any standard COM Automation data type, such as INT or BSTR. The GetProperty and SetProperty APIs take the property name and a variable of the appropriate data type. Methods are referred to by a descriptive string, such as InsertChart. A method takes a set of parameters that are of different COM Automation data types and returns a COM Automation data type.
The following is an example of a COM Automation method prototype in COM Interface Definition Language (IDL) grammar:
[id(0x6003000)]
long Post([in, out] long* lngAccountNo,
          [in, out] long* lngAmount,
          [in, out] BSTR* strResult);
Interfaces define object methods and properties. COM IDL is used to specify interfaces that are defined on COM objects.
Microsoft provides a tool called the OLE/COM Object Viewer with Microsoft Visual Studio for browsing the properties and methods of COM objects on a local system. This tool enables you to quickly and easily determine the properties and methods that each COM object exposes. See Figure 3-1 for an example.
In a typical use of Oracle COM Automation Feature, you design a Java class or PL/SQL block to create and manipulate a COM object. The class or code block performs the following steps:
Creates the COM object as follows:
In PL/SQL, using CreateObject
In Java, using a constructor or the Create method
Manipulates the COM object calling the following APIs:
GetProperty to get a property value
SetProperty to set a property value to a new value
Calls Invoke to call a method
To prepare for the Invoke call, you use InitArg and SetArg to package the argument to be sent to the COM Automation method.
Calls GetLastError in PL/SQL to get the most recent error information
Destroys the object using DestroyObject in PL/SQL or Destroy in Java
This section lists and then describes the APIs available for Oracle COM Automation Feature.
This section describes the PL/SQL APIs for manipulating COM objects using the COM Automation interface. Each of the following PL/SQL stored procedures resides in the package ORDCOM.
This API instantiates a COM object in a COM Automation server.
Syntax
FUNCTION CreateObject(progid VARCHAR2, reserved BINARY_INTEGER, servername VARCHAR2, objecttoken OUT BINARY_INTEGER) RETURN BINARY_INTEGER;
Remarks
The created COM Automation object is freed with a corresponding call to DestroyObject. This nullifies the internal representation of the object in the Oracle COM Automation Feature and releases all interfaces associated with the object.
This function returns 0 when successful, or a nonzero value for HRESULT when an error occurs.
Code Sample
HRESULT BINARY_INTEGER;
applicationToken BINARY_INTEGER:=-1;
HRESULT :=ORDCOM.CreateObject('Excel.Application', 0, '', applicationToken);
IF (HRESULT!=0) THEN
  dbms_output.put_line(HRESULT);
END IF;
This API destroys a created COM Automation object.
Syntax
FUNCTION DestroyObject(objecttoken BINARY_INTEGER) RETURN BINARY_INTEGER;
| Where | Is | 
|---|---|
| objecttoken | the object token of a COM Automation object previously created by CreateObject. | 
Remarks
Calling DestroyObject nullifies the internal representation of the object in the Oracle COM Automation Feature and releases all interfaces associated with the object.
This function returns 0 when successful, or a nonzero value of HRESULT when an error occurs.
Code Sample
HRESULT BINARY_INTEGER; applicationToken BINARY_INTEGER:=-1; /* Assume applicationToken is initialized. */ HRESULT:=ORDCOM.DestroyObject(applicationToken); IF (HRESULT!=0) THEN dbms_output.put_line(HRESULT);
This API obtains the COM Automation error information about the last error that occurred.
Syntax
FUNCTION GetLastError(source OUT VARCHAR2, description OUT VARCHAR2, helpfile OUT VARCHAR2, helpid OUT BINARY_INTEGER) RETURN BINARY_INTEGER;
| Where | Is | 
|---|---|
| source | the source of the error information. If specified, it must be a local CHARorVARCHARvariable. The return value is truncated to fit the local variable if necessary. | 
| description | the description of the error. If specified, it must be a local CHARorVARCHARvariable. The return value is truncated to fit the local variable if necessary. | 
| helpfile | the Help file for the COM Automation object. If specified, it must be a local CHARorVARCHARvariable. The return value is truncated to fit the local variable if necessary. |