Object References Design Time: Artifact Generation

Oracle JCA Adapter for Database 9-99 Suppose that the type of parameter A was also a user-defined object type and that the definition of OBJ changed accordingly, as shown in the following example: SQL CREATE TYPE FOO AS OBJECT X NUMBER, Y NUMBER, Z NUMBER; SQL CREATE TYPE OBJ AS OBJECT A FOO, B SqlType, C SqlType, ...; In such a case, the API remains unchanged. Elements corresponding to unwanted attributes in the definition of FOO can also be removed regardless of their type. So, for example, if Y is not required, then its element in the complexType definition of FOO can be removed in the XSD file. Pruning the XSD file in this fashion improves the run-time performance of the adapter and can significantly reduce memory consumption, as well.

9.7.4 Run Time: Before Stored Procedure Invocation

This section discusses important considerations of stored procedure support and a brief overview of some important details regarding what happens before the invocation of a stored procedure or function. This section includes the following topics: ■ Section 9.7.4.1, Value Binding ■ Section 9.7.4.2, Data Type Conversions

9.7.4.1 Value Binding

Consider the extraction of values from the XML file and how the run time works given those values. The possible cases for data in the XML file corresponding to the value of a parameter whose type is one of the supported primitive data types are as follows: 1. The value of an element is specified for example, X100X, here X=100. 2. The value of an element is not specified for example, X, here X=null. 3. The value is explicitly specified as null for example, X xsi:nil=true, here X=null. 4. The element is not specified in the XML file at all for example, X = default value. In the first case, the value is taken from the XML file as is and is converted to the appropriate object according to its type. That object is then bound to its corresponding parameter during preparation of the stored procedure invocation. Note: Only attributes in user-defined object types can be pruned. You cannot prune remove a parameter of the stored procedure by removing its element from the InputParameters root element. This can result in an error at run time unless the parameter has a default clause. Note: There is one notable difference that distinguishes Microsoft SQL Server from IBM DB2, MySQL, and AS400. SQL Server supports parameters that can include a default value in the definition of a stored procedure. Because IBM DB2, MySQL, and AS400 do not support parameter defaults, every parameter must be represented as an element in the instance XML. 9-100 Oracle Fusion Middleware Users Guide for Technology Adapters In the second and third cases, the actual value extracted from the XML file is null. The type converter accepts null and returns it without any conversion. The null value is bound to its corresponding parameter regardless of its type. Essentially, this is the same as passing null for parameter X. The fourth case has two possibilities. The parameter either has a default clause or it does not. If the parameter has a default clause, then the parameter can be excluded from the invocation of the stored procedure. This allows the default value to be used for the parameter. If the parameter is included, then the value of the parameter is used, instead. If the parameter does not have a default clause, then the parameter must be included in the invocation of the procedure. Elements for all parameters of a function must be specified. If an element in the instance XML is missing, then the function is invoked with fewer arguments than is expected. A null value is bound to the parameter by default: SQL CREATE PROCEDURE PROC X IN INTEGER DEFAULT 0 AS BEGIN … END; Here, no value is bound to the parameter. In fact, the parameter can be excluded from the invocation of the stored procedure. This allows the value of 0 to default for parameter X. To summarize, the following PLSQL is executed in each of these three cases: 1. BEGIN PROC X=?; END; - X = 100 2. BEGIN PROC X=?; END; - X = null 3. There are two possibilities: a. BEGIN PROC ; END; - X = 0 X has a default clause b. BEGIN PROC X=?; END; - X = null X does not have a default clause With the exception of default clause handling, these general semantics also apply to item values of a collection or attribute values of an OBJECT whose types are one of the supported primitive data types. The semantics of X when the type is user-defined are, however, quite different. For a collection, whether it is a VARRAY or a nested table, the following behavior can be expected, given a type definition such as SQL CREATE TYPE ARRAY AS VARRAY 5 OF VARCHAR2 10; and XML for a parameter, X, which has type ARRAY, that appears as follows: X X_ITEM xsi:nil=true X_ITEMHelloX_ITEM X_ITEM xsi:nil=true X_ITEMWorldX_ITEM X The first and third elements of the VARRAY are set to null. The second and fourth are assigned their respective values. No fifth element is specified in the XML file; therefore, the VARRAY instance has only four elements. Assume an OBJECT definition such as SQL CREATE TYPE OBJ AS OBJECT A INTEGER, B INTEGER, C INTEGER; and XML for a parameter, X, which has type OBJ, that appears as