|Oracle8i SQLJ Developer's Guide and Reference
Release 3 (8.1.7)
Part Number A83723-01
Weakly typed objects, references, and collections are supported by SQLJ. Their use is not generally recommended, and there are some specific restrictions, but in some circumstances they can be useful. For example, you might 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 instances instead of the strongly typed custom object, reference, and collection classes that implement the
CustomDatum interface or the strongly typed custom object classes that implement the
SQLData interface. (Note that if you use
SQLData implementations for your custom object classes, you will have no choice but to use weakly typed custom reference instances.)
The following weak types can be used for iterator columns or host expressions in Oracle SQLJ:
oracle.sql.REFfor object references
In host expressions, they are supported as follows:
Using these weak types 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 perform 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 a stored procedure or function call
OUTparameter in a 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 to materialize an instance of a user-defined type in Java.