|Oracle8i SQLJ Developer's Guide and Reference
Weakly typed objects, references, and collections are supported by SQLJ. Their general use is not recommended and there are some specific restrictions, but in some circumstances they may be useful. For example, you may have generic code that can use "any
STRUCT" or "any
REF" (although if this uses dynamic SQL it would require coding in JDBC instead of SQLJ).
In using Oracle objects, references, or collections in a SQLJ application, you have the option of using generic and weakly typed
oracle.sql classes instead of the strongly typed custom Java classes that implement the
oracle.sql classes can be used for iterator columns or host expressions in Oracle SQLJ:
In host expressions they are supported as follows:
Using these classes is not generally recommended, however, as you would lose all the advantages of the strongly typed paradigm that SQLJ offers.
Each attribute in a
STRUCT object or each element in an
ARRAY object is stored in an
oracle.sql.Datum object, with the underlying data being in the form of the appropriate
oracle.sql.* type (such as
oracle.sql.CHAR). Attributes in a
STRUCT object are nameless.
Because of the generic nature of the
ARRAY classes, SQLJ cannot do type checking where objects or collections are written to or read from instances of these classes.
It is generally recommended that you use custom Java classes for objects, references, and collections, preferably classes generated by JPublisher.
A weakly typed object (
STRUCT instance), reference (
REF instance), or collection (
ARRAY instance) cannot be used in host expressions in the following circumstances:
INparameter if null
INOUTparameter in stored procedure or function call
OUTparameter in stored function result-expression
They cannot be used in these ways because there is no way to know the underlying SQL type name (such as
Person), which is required by the Oracle JDBC driver in order to materialize an instance of a user-defined type in Java.