XS_NAMESPACE Package
The XS_NAMESPACE
package includes subprograms to create, manage, and delete namespace templates and attributes.
Object Types, Constructor Functions, Synonyms, and Grants
The following object types, constructor functions, synonyms, and GRANT
statements are defined for this package.
-- Type definition for namespace template attribute CREATE OR REPLACE TYPE XS$NS_ATTRIBUTE AS OBJECT ( -- Member Variables -- Name of the namespace template attribute -- Must be unique within a namespace template -- Cannot be null name VARCHAR2(4000), -- Default value assigned to the attribute default_value VARCHAR2(4000), -- Trigger events associated with the attribute -- Allowed values are : -- 0 : NO_EVENT -- 1 : FIRST_READ_EVENT -- 2 : UPDATE_EVENT -- 3 : FIRST_READ_PLUS_UPDATE_EVENT attribute_events NUMBER, -- Constructor function CONSTRUCTOR FUNCTION XS$NS_ATTRIBUTE (name IN VARCHAR2, default_value IN VARCHAR2 := NULL, attribute_events IN NUMBER := 0) RETURN SELF AS RESULT, -- Return the name of the attribute MEMBER FUNCTION GET_NAME RETURN VARCHAR2, -- Return the default value of the attribute MEMBER FUNCTION GET_DEFAULT_VALUE RETURN VARCHAR2, -- Return the trigger events associated with attribute MEMBER FUNCTION GET_ATTRIBUTE_EVENTS RETURN NUMBER, -- Mutator procedures -- Set the default value for the attribute MEMBER PROCEDURE SET_DEFAULT_VALUE(default_value IN VARCHAR2), -- Associate trigger events to the attribute MEMBER PROCEDURE SET_ATTRIBUTE_EVENTS(attribute_events IN NUMBER) ); CREATE OR REPLACE TYPE XS$NS_ATTRIBUTE_LIST AS VARRAY(1000) OF XS$NS_ATTRIBUTE;
Summary of XS_NAMESPACE Subprograms
Table 11-9 Summary of XS_NAMESPACE Subprograms
Subprogram | Description |
---|---|
Creates a new namespace template. |
|
Adds one or more attributes to an existing namespace template. |
|
Removes one or more attributes from a namespace template. |
|
Assigns a handler function for the specified namespace template. |
|
Sets a description string for the specified namespace template. |
|
Deletes the specified namespace template. |
This section describes the following XS_NAMESPACE subprograms:
CREATE_TEMPLATE Procedure
The CREATE_TEMPLATE procedure creates a new namespace template.
Syntax
XS_NAMESPACE.CREATE_TEMPLATE ( name IN VARCHAR2, attr_list IN XS$NS_ATTRIBUTE_LIST := NULL, schema IN VARCHAR2 := NULL, package IN VARCHAR2 := NULL, function IN VARCHAR2 := NULL, acl IN VARCHAR2 := 'SYS.NS_UNRESTRICTED_ACL' description IN VARCHAR2 := NULL);
Parameters
Parameter | Description |
---|---|
|
The name of the namespace template to be created. |
|
The attributes contained in the namespace template together with their default values and associated attribute events, such as |
|
The schema that contains the handler function for the namespace template. |
|
The package that contains the handler function for the namespace template. |
|
The handler function for the namespace template. The handler function is called when an attribute event occurs. |
|
The name of the ACL for this namespace template. If no ACL is provided, the default is the predefined ACL |
|
An optional description string for the namespace template. |
Examples
The following example creates a namespace template called POAttrs
. The namespace template contains a list of attributes defined by attrlist
. The handler function for the namespace template is called Populate_Order_Func
. This handler function is part of the Orders_Pckg
package, which is contained in the SCOTT
schema. The namespace template has NS_UNRESTRICTED_ACL
set on the template, which allows unrestricted operation on namespaces created from the template.
DECLARE attrlist XS$NS_ATTRIBUTE_LIST; BEGIN attrlist := XS$NS_ATTRIBUTE_LIST(); attrlist.extend(2); attrlist(1) := XS$NS_ATTRIBUTE('desc', 'general'); attrlist(2) := XS$NS_ATTRIBUTE(name=>'item_no', attribute_events=>XS_NAMESPACE.FIRSTREAD_EVENT); SYS.XS_NAMESPACE.CREATE_TEMPLATE('POAttrs', attrlist, 'SCOTT', 'Orders_Pckg','Populate_Order_Func', 'SYS.NS_UNRESTRICTED_ACL', 'Purchase Order Attributes'); END;
ADD_ATTRIBUTES Procedure
The ADD_ATTRIBUTES
procedure adds one or more attributes to an existing namespace template.
Syntax
XS_NAMESPACE.ADD_ATTRIBUTES ( template IN VARCHAR2, attribute IN VARCHAR2, default_value IN VARCHAR2 := NULL, attribute_events IN PLS_INTEGER := XS_NAMESPACE.NO_EVENT); XS_NAMESPACE.ADD_ATTRIBUTES ( template IN VARCHAR2, attr_list IN XS$NS_ATTRIBUTE_LIST);
Parameters
Parameter | Description |
---|---|
|
The name of the namespace templates to which the attribute(s) is/are to be added. |
|
The name of the attribute to be added. |
|
The list of attributes to be added. |
|
The default value of the attribute. |
|
The attribute event associated with the attribute, such as update event. |
Examples
The following example adds an attribute called item_type
to the POAttrs
namespace. It also specifies a default value and attribute event for the new attribute that is added.
BEGIN SYS.XS_NAMESPACE.ADD_ATTRIBUTES(template=>'POAttrs',attribute=>'item_type', default_value=>'generic', attribute_events=>XS_NAMESPACE.update_event); END;
REMOVE_ATTRIBUTES Procedure
The REMOVE_ATTRIBUTES
procedure removes one or more attributes from a namespace template. If no attribute names are specified, then all attributes are removed from the namespace template.
Syntax
XS_NAMESPACE.REMOVE_ATTRIBUTES ( template IN VARCHAR2, attribute IN VARCHAR2); XS_NAMESPACE.REMOVE_ATTRIBUTES ( template IN VARCHAR2, attr_list IN XS$LIST); XS_NAMESPACE.REMOVE_ATTRIBUTES ( template IN VARCHAR2);
Parameters
Parameter | Description |
---|---|
|
The name of the namespace template from which the attribute(s) is/are to be removed. |
|
The name of the attribute to be removed. |
|
The list of attribute names to be removed. |
Examples
The following example removes the item_type
attribute from the POAttrs
namespace.
BEGIN SYS.XS_NAMESPACE.REMOVE_ATTRIBUTES('POAttrs','item_type'); END;
The following example removes all attributes from the POAttrs
namespace template.
BEGIN SYS.XS_NAMESPACE.REMOVE_ATTRIBUTES('POAttrs'); END;
SET_HANDLER Procedure
The SET_HANDLER
procedure assigns a handler function for the specified namespace template.
Syntax
XS_NAMESPACE.SET_HANDLER ( template IN VARCHAR2, schema IN VARCHAR2, package IN VARCHAR2, function IN VARCHAR2);
Parameters
Parameter | Description |
---|---|
|
The name of the namespace template for which the handler function is to be set. |
|
The schema containing the handler package and function. |
|
The name of the package that contains the handler function. |
|
The name of the handler function for the namespace template. |
Examples
The following example sets a handler function, called Populate_Order_Func
, for the POAttrs
namespace template.
BEGIN SYS.XS_NAMESPACE.SET_HANDLER('POAttrs','SCOTT', 'Orders_Pckg','Populate_Order_Func'); END;
SET_DESCRIPTION Procedure
The SET_DESCRIPTION
procedure sets a description string for the specified namespace template.
Syntax
XS_NAMESPACE.SET_DESCRIPTION ( template IN VARCHAR2, description IN VARCHAR2);
Parameters
Parameter | Description |
---|---|
|
The name of the namespace template whose description is to be set. |
|
A description string for the specified namespace template. |
Examples
The following example sets a description string for the POAttrs
namespace template.
BEGIN SYS.XS_NAMESPACE.SET_DESCRIPTION('POAttrs','Purchase Order Attributes'); END;
DELETE_TEMPLATE Procedure
The DELETE_TEMPLATE
procedure deletes the specified namespace template.
Syntax
XS_NAMESPACE.DELETE_TEMPLATE( template IN VARCHAR2, delete_option IN PLS_INTEGER := XS_ADMIN_UTIL.DEFAULT_OPTION);
Parameters
Parameter | Description |
---|---|
|
The name of the namespace template to be deleted. |
|
The delete option to use. To the namespace template, the behavior of the following options is the same:
|
Examples
The following example deletes the POAttrs namespace template using the default delete option.
BEGIN SYS.XS_NAMESPACE.DELETE_TEMPLATE('POAttrs',XS_ADMIN_UTIL.DEFAULT_OPTION); END;