Oracle® Database PL/SQL Packages and Types Reference 10g Release 2 (10.2) Part Number B14258-02 |
|
|
View PDF |
An ANYTYPE
TYPE
can contain a type description of any persistent SQL type, named or unnamed, including object types and collection types. It can also be used to construct new transient type descriptions.
New persistent types can only be created using the CREATE TYPE
statement. Only new transient types can be constructed using the ANYTYPE
interfaces.
This chapter discusses the following:
Table 184-1 ANYTYPE Type Subprograms
Subprogram | Description |
---|---|
Creates a new instance of |
|
Sets any additional information required for constructing a |
|
Adds an attribute to an |
|
Ends creation of a transient |
|
Returns an |
|
Gets the type information for the |
|
Gets the type information for an attribute of the type (if it is of |
This procxedure creates a new instance of ANYTYPE
which can be used to create a transient type description.
Syntax
STATIC PROCEDURE BEGINCREATE( typecode IN PLS_INTEGER, atype OUT NOCOPY ANYTYPE);
Parameters
Table 184-2 BEGINCREATE Procedure Parameters
Parameter | Description |
---|---|
|
Use a constant from Typecodes for user-defined type:
Typecodes for builtin types:
|
|
|
This procedure sets any additional information required for constructing a COLLECTION
or builtin type.
Syntax
MEMBER PROCEDURE SETINFO( self IN OUT NOCOPY ANYTYPE, prec IN PLS_INTEGER, scale IN PLS_INTEGER, len IN PLS_INTEGER, csid IN PLS_INTEGER, csfrm IN PLS_INTEGER, atype IN ANYTYPE DEFAULT NULL, elem_tc IN PLS_INTEGER DEFAULT NULL, elem_count IN PLS_INTEGER DEFAULT 0);
Parameters
Table 184-3 SETINFO Procedure Parameters
Parameter | Description |
---|---|
|
The transient |
|
Optional.Required if typecode represents a Give precision and scale. Ignored otherwise. |
|
Optional.Required if typecode represents a Give precision and scale. Ignored otherwise. |
|
Optional. Required if typecode represents a |
|
Required if typecode represents types requiring character information such as |
|
Required if typecode represents types requiring character information such as |
|
Optional. Required if collection element typecode is a user-defined type such as |
The Following Parameters Are Required For Collection Types
Table 184-4 SETINFO Procedure Parameters - Collection Types
Parameter | Description |
---|---|
|
Must be of the collection element's typecode (from |
|
Pass 0 for |
Exceptions
DBMS_TYPES.INVALID_PARAMETER
: Invalid Parameters (typecode, typeinfo)
DBMS_TYPES.INCORRECT_USAGE
: Incorrect usage (cannot call after calling ENDCREATE
, and similar actions.)
Usage Notes
It is an error to call this function on an ANYTYPE
that represents a persistent user defined type.
This procedure adds an attribute to an ANYTYPE
(of typecode DBMS_TYPES
.TYPECODE_OBJECT
).
Syntax
MEMBER PROCEDURE ADDATTR( self IN OUT NOCOPY ANYTYPE, aname IN VARCHAR2, typecode IN PLS_INTEGER, prec IN PLS_INTEGER, scale IN PLS_INTEGER, len IN PLS_INTEGER, csid IN PLS_INTEGER, csfrm IN PLS_INTEGER, attr_type IN ANYTYPE DEFAULT NULL);
Parameters
Table 184-5 ADDATTR Procedure Parameters
Parameter | Description |
---|---|
|
The transient |
|
Optional. Attribute's name. Could be |
|
Attribute's typecode. Can be built-in or user-defined typecode (from |
|
Optional. Required if typecode represents a |
|
Optional. Required if typecode represents a |
|
Optional. Required if typecode represents a |
|
Optional. Required if typecode represents a type requiring character information, such as |
|
Optional. Required if typecode represents a type requiring character information, such as |
|
Optional. |
Exceptions
DBMS_TYPES.INVALID_PARAMETERS
: Invalid Parameters (typecode, typeinfo)
DBMS_TYPES.INCORRECT_USAGE
: Incorrect usage (cannot call after calling EndCreate
, and similar actions.)
This procedure ends creation of a transient ANYTYPE
. Other creation functions cannot be called after this call.
Syntax
MEMBER PROCEDURE ENDCREATE( self IN OUT NOCOPY ANYTYPE);
Parameter
Table 184-6 ENDCREATE Procedure Parameter
Parameter | Description |
---|---|
|
The transient |
This procedure returns an ANYTYPE
corresponding to a persistent type created earlier using the CREATE
TYPE
SQL statement.
Syntax
STATIC FUNCTION GETPERSISTENT( schema_name IN VARCHAR2, type_name IN VARCHAR2, version IN VARCHAR2 DEFAULT NULL) RETURN ANYTYPE;
Parameters
Table 184-7 GETPERSISTENT Function Parameters
Parameter | Description |
---|---|
|
Schema name of the type. |
|
Type name. |
|
Type version. |
Return Values
An ANYTYPE
corresponding to a persistent type created earlier using the CREATE
TYPE
SQL statement.
This function gets the type information for the ANYTYPE
.
Syntax
MEMBER FUNCTION GETINFO ( self IN ANYTYPE, prec OUT PLS_INTEGER, scale OUT PLS_INTEGER, len OUT PLS_INTEGER, csid OUT PLS_INTEGER, csfrm OUT PLS_INTEGER, schema_name OUT VARCHAR2, type_name OUT VARCHAR2, version OUT varchar2, count OUT PLS_INTEGER) RETURN PLS_INTEGER;
Parameters
Table 184-8 GETINFO Function Parameters
Parameter | Description |
---|---|
|
The |
|
If typecode represents a number. Gives precision and scale. Ignored otherwise. |
|
If typecode represents a number. Gives precision and scale. Ignored otherwise. |
|
If typecode represents a |
|
If typecode represents a type requiring character information such as: |
|
If typecode represents a type requiring character information such as: |
|
Type's schema (if persistent). |
|
Type's typename. |
|
Type's version. |
|
If self is a |
Return Values
The typecode of self.
Exceptions
DBMS_TYPES.INVALID_PARAMETERS
: Invalid Parameters (position is beyond bounds or the ANYTYPE
is not properly Constructed).
This function gets the type information for an attribute of the type (if it is of TYPECODE_OBJECT
). Gets the type information for a collection's element type if the self parameter is of a collection type.
Syntax
MEMBER FUNCTION GETATTRELEMINFO ( self IN ANYTYPE, pos IN PLS_INTEGER, prec OUT PLS_INTEGER, scale OUT PLS_INTEGER, len OUT PLS_INTEGER, csid OUT PLS_INTEGER, csfrm OUT PLS_INTEGER, attr_elt_type OUT ANYTYPE aname OUT VARRCHAR2) RETURN PLS_INTEGER;
Parameters
Table 184-9 GETATTRELEMINFO Function Parameters
Parameter | Description |
---|---|
|
The |
|
If self is of |
|
If attribute/collection element typecode represents a |
|
If attribute/collection element typecode represents a |
|
If typecode represents a |
|
If typecode represents a type requiring character information such as: |
|
If attribute/collection element typecode represents a user-defined type, this returns the |
|
Attribute name (if it is an attribute of an object type, |
Return Values
The typecode of the attribute or collection element.
Exceptions
DBMS_TYPES.INVALID_PARAMETERS:
Invalid Parameters (position is beyond bounds or the ANYTYPE is not properly constructed).