JCA File Design Time: Artifact Generation

9-94 Oracle Fusion Middleware Users Guide for Technology Adapters The db namespace is used to distinguish attributes used during run time from standard XML schema attributes. The db:type attribute is used to indicate what the database type is so that a suitable JDBC type mapping can be obtained at run time. The db:index attribute is used as an optimization by both the design-time and run-time components to ensure that the parameters are arranged in the proper order. Parameter indexes begin at 1 for procedures and 0 for functions. The return value of a function is represented as an OutputParameter element whose name is the name of the function and whose db:index is 0. The db:default attribute is used to indicate whether or not a parameter has a default clause. The minOccurs value is set to 0 to allow for an IN parameter to be removed from the XML file. This is useful when a parameter has a default clause defining a value for the parameter for example, X IN INTEGER DEFAULT 0. At run time, if no element is specified for the parameter in the XML file, the parameter is omitted from the invocation of the stored procedure, thus allowing the default value to be used. Each parameter can appear at most once in the invocation of a stored procedure or function. Therefore, maxOccurs, whose default value is always 1, is always omitted from elements representing parameters. The nillable attribute is always set to true to allow the corresponding element in the instance XML to have a null value for example, X or XX. In some cases, however, to pass an element such as this, which does have a null value, you must state this explicitly for example, X xsi:nil=true. The namespace, xsi, used for the nillable attribute, must be declared explicitly in the instance XML for example, xmlns:xsi= http:www.w3.org2001XMLSchema -instance.

9.7.3.5 User-Defined Types

The Adapter Configuration Wizard can also generate valid definitions for user-defined types such as collections VARRAY and nested tables and OBJECT. These are created as complexType definitions in the XSD file. For VARRAY, the complexType definition defines a single element in its sequence, called name_ITEM, where name is the name of the VARRAY element. All array elements in the XML file are so named. Given the following VARRAY type definition, SQL CREATE TYPE FOO AS VARRAY 5 OF VARCHAR2 10; and a VARRAY element, X, whose type is FOO, the following complexType is generated: complexType name=FOO sequence element name=X_ITEM db:type=VARCHAR2 minOccurs=0 maxOccurs=5 nillable=true simpleType db:type db:type=VARCHAR2 SQL or PLSQL type db:index db:index=1 Position of a parameter db:default db:default=true Has a default clause minOccurs minOccurs=0 Minimum occurrences maxOccurs maxOccurs=1 Maximum occurrences nillable nillable=true Permits null values Table 9–18 Cont. Generated XSD Attributes Attribute Example Purpose Oracle JCA Adapter for Database 9-95 restriction base=string maxLength value=10 restriction simpleType sequence complexType The minOccurs value is 0 to allow for an empty collection. The maxOccurs value is set to the maximum number of items that the collection can hold. Note that the db:index attribute is not used. Having nillable set to true allows individual items in the VARRAY to be null. Note the use of the restriction specified on the element of the VARRAY, FOO. This is used on types such as CHAR and VARCHAR2, whose length is known from the declaration of the VARRAY or nested table. It specifies the type and maximum length of the element. An element value that exceeds the specified length causes the instance XML to fail during schema validation. The attribute values of a parameter declared to be of type FOO look as follows in the generated XSD: element name=X type=db:FOO db:type=Array db:index=1 minOccurs=0 nillable=true The type and db:type values indicate that the parameter is represented as an array defined by the complexType called FOO in the XSD file. The value for db:index is whatever the position of that parameter is in the stored procedure. A nested table is treated almost identically to a VARRAY. The following nested table type definition, SQL CREATE TYPE FOO AS TABLE OF VARCHAR2 10; is also generated as a complexType with a single element in its sequence, called name _ITEM. The element has the same attributes as in the VARRAY example, except that the maxOccurs value is unbounded because nested tables can be of arbitrary size. complexType name=FOO sequence element name=X_ITEM … maxOccurs=unbounded nillable=true … element sequence complexType An identical restriction is generated for the X_ITEM element in the VARRAY. The attributes of a parameter, X, declared to be of this type, are the same as in the VARRAY example. Note that collections Varray and nested table are not supported if they are defined inside of a PLSQL package specification. For example: SQL create package pkg as type vary is varray10 of number; type ntbl is table of varchar2100; procedure testv in vary, n in ntbl; end; If a user selects the test procedure in the Adapter Configuration Wizard for stored procedures, an error occurs stating that the types are not supported. However, if the