CREATE TYPE BODY v12
Name
CREATE TYPE BODY
-- define a new object type body.
Synopsis
where method_spec
is:
and subprogram_spec
is:
Description
CREATE TYPE BODY
defines a new object type body. CREATE OR REPLACE TYPE BODY
will either create a new object type body, or replace an existing body.
If a schema name is included, then the object type body is created in the specified schema. Otherwise it is created in the current schema. The name of the new object type body must match an existing object type specification in the same schema. The new object type body name must not match any existing object type body in the same schema unless the intent is to update the definition of an existing object type body, in which case use CREATE OR REPLACE TYPE BODY
.
Parameters
name
The name (optionally schema-qualified) of the object type for which a body is to be created.
MEMBER
STATIC
Specify MEMBER
if the subprogram operates on an object instance. Specify STATIC
if the subprogram operates independently of any particular object instance.
proc_name
The name of the procedure to create.
SELF [ IN | IN OUT ] name
For a member method there is an implicit, built-in parameter named SELF
whose data type is that of the object type being defined. SELF
refers to the object instance that is currently invoking the method. SELF
can be explicitly declared as an IN
or IN OUT
parameter in the parameter list. If explicitly declared, SELF
must be the first parameter in the parameter list. If SELF
is not explicitly declared, its parameter mode defaults to IN OUT
for member procedures and IN
for member functions.
argname
The name of an argument. The argument is referenced by this name within the method body.
argtype
The data type(s) of the method’s arguments. The argument types may be a base data type or a user-defined type such as a nested table or an object type. A length must not be specified for any base type - for example, specify VARCHAR2
, not VARCHAR2(10)
.
DEFAULT value
Supplies a default value for an input argument if one is not supplied in the method call. DEFAULT
may not be specified for arguments with modes IN OUT
or OUT
.
program_body
The pragma, declarations, and SPL statements that comprise the body of the function or procedure. The pragma may be PRAGMA AUTONOMOUS_TRANSACTION
to set the function or procedure as an autonomous transaction.
func_name
The name of the function to create.
rettype
The return data type, which may be any of the types listed for argtype
. As for argtype
, a length must not be specified for rettype
.
Examples
Create the object type body for object type emp_obj_typ
given in the example for the CREATE TYPE
command.
Create the object type body for object type dept_obj_typ
given in the example for the CREATE TYPE
command.
See Also