Oracle DBMS_XEVENT
Version 12.2.0.1

General Information
Library Note Morgan's Library Page Header
Coming to OpenWorld 2018? Be sure to visit the TidalScale booth in Moscone South and learn how to solve performance problems and lower costs with Software Defined Servers. Before you visit the booth, or if you can't make it this year, check out TidalScale at www.tidalscale.com. Be sure to click on the Solutions link and look through the Oracle resources.
Purpose Internal support with event related types and subprograms
AUTHID CURRENT_USER
Constants
Name Data Type Value
Event ID Constants
RENDER_EVENT PLS_INTEGER 1
PRE_CREATE_EVENT PLS_INTEGER 2
POST_CREATE_EVENT PLS_INTEGER 3
PRE_DELETE_EVENT PLS_INTEGER 4
POST_DELETE_EVENT PLS_INTEGER 5
PRE_UPDATE_EVENT PLS_INTEGER 6
POST_UPDATE_EVENT PLS_INTEGER 7
PRE_LOCK_EVENT PLS_INTEGER 8
POST_LOCK_EVENT PLS_INTEGER 9
PRE_UNLOCK_EVENT PLS_INTEGER 10
POST_UNLOCK_EVENT PLS_INTEGER 11
PRE_LINKIN_EVENT PLS_INTEGER 12
POST_LINKIN_EVENT PLS_INTEGER 13
PRE_LINKTO_EVENT PLS_INTEGER 14
POST_LINKTO_EVENT PLS_INTEGER 15
PRE_UNLINKIN_EVENT PLS_INTEGER 16
POST_UNLINKIN_EVENT PLS_INTEGER 17
PRE_UNLINKFROM_EVENT PLS_INTEGER 18
POST_UNLINKFROM_EVENT PLS_INTEGER 19
PRE_CHECKIN_EVENT PLS_INTEGER 20
POST_CHECKIN_EVENT PLS_INTEGER 21
PRE_CHECKOUT_EVENT PLS_INTEGER 22
POST_CHECKOUT_EVENT PLS_INTEGER 23
PRE_UNCHECKOUT_EVENT PLS_INTEGER 24
POST_UNCHECKOUT_EVENT PLS_INTEGER 25
PRE_VERSIONCONTROL_EVENT PLS_INTEGER 26
POST_VERSIONCONTROL_EVENT PLS_INTEGER 27
PRE_OPEN_EVENT PLS_INTEGER 28
POST_OPEN_EVENT PLS_INTEGER 29
PRE_INCONSISTENTUPDATE_EVENT PLS_INTEGER 30
POST_INCONSISTENTUPDATE_EVENT PLS_INTEGER 31
NFS Constants
OPEN_ACCESS_READ PLS_INTEGER 1
OPEN_ACCESS_WRITE PLS_INTEGER 2
OPEN_ACCESS_READ_WRITE PLS_INTEGER 3
OPEN_DENY_NONE PLS_INTEGER 0
OPEN_DENY_READ PLS_INTEGER 1
OPEN_DENY_WRITE PLS_INTEGER 2
Data Types SUBTYPE XDBEventID IS PLS_INTEGER RANGE 1 .. 31;

-- Event interface types
SUBTYPE EventType IS RAW(32);
SUBTYPE XDBRepositoryEvent is RAW(32);

TYPE XDBEvent is RECORD (id RAW(32));
TYPE XDBHandlerList is RECORD (id RAW(32));
TYPE XDBHandler is RECORD (id RAW(32));
TYPE XDBPath is RECORD (id RAW(32));
TYPE XDBLink is RECORD (id RAW(32));
TYPE XDBLock is RECORD (id RAW(32));
Dependencies
DBMS_STANDARD DBMS_XDBRESOURCE XMLTYPE
DBMS_XDBEVENT_LIB DBMS_XDB_UTIL  
Documented Yes
First Available 12.1.0.1
Security Model Owned by XDB with EXECUTE granted to PUBLIC
Source {ORACLE_HOME}/rdbms/admin/dbmsxev.sql
Subprograms
 
CLEAR
Clears the handler list dbms_xevent.clear(hl IN XDBHandlerList);
TBD
 
getApplicationData
Returns the <applicationData> element extracted from the resource  configuration that defines the invoking handler dbms_xevent.getApplicationData(ev IN XDBRepositoryEvent)
RETURN SYS.XMLType;
TBD
 
getChildOID
Returns the OID of the resource that the link is pointing to dbms_xevent.getChildOID(link IN XDBLink)
RETURN RAW;
TBD
 
getCurrentUser
Returns the name of the user executing the operation that triggers the event dbms_xevent.getCurrentUser(ev IN XDBEvent)
RETURN VARCHAR2;
See Demo At Page Bottom
 
getDAVOwner
Returns the DAV:owner if this is a DAV lock. Otherwise null dbms_xevent.getDAVOwner(lk in XDBLock)
RETURN VARCHAR2;
TBD
 
getDAVToken
Returns the token id if this is a DAV lock. Otherwise null dbms_xevent.getDAVToken(lk in XDBLock)
RETURN VARCHAR2;
TBD
 
getDepth
Returns the depth of the lock (either 0 or INFINITY_DEPTH) dbms_xevent.getDepth(lk in XDBLock)
RETURN PLS_INTEGER;
TBD
 
getEvent
Returns the ID identifying the triggering event dbms_xevent.getEvent(ev IN XDBEvent)
RETURN XDBEventID;
TBD
 
getExpiry
If DAV lock returns the date and time at which the lock will expire; otherwise returns null dbms_xevent.getExpiry(lk in XDBLock)
RETURN TIMESTAMP;
TBD
 
getFirst
Returns the first handler in the list dbms_xevent.getFirst(hl IN XDBHandlerList)
RETURN XDBHandler;
TBD
 
getHandlerList
Returns The list of handlers that will be executed after the currently executing handler dbms_xevent.getHandlerList(ev IN XDBRepositoryEvent)
RETURN XDBHandlerList;
TBD
 
getInterface
Returns the top-level interface used to initiate the operation that triggered the event. This could be "HTTP", "FTP" or "SQL" dbms_xevent.getInterface(ev IN XDBRepositoryEvent)
RETURN VARCHAR2;
TBD
 
getLanguage
Returns the implementation language of the handler dbms_xevent.getLanguage(handler IN XDBHandler)
RETURN VARCHAR2;
TBD
 
getLink
Rreturns an XDBLink object for the target resource dbms_xevent.getLink(ev IN XDBRepositoryEvent)
RETURN XDBLink;
TBD
 
getLinkName
Returns the name of the link dbms_xevent.getLinkName(link IN XDBLink)
RETURN VARCHAR2;
TBD
 
getLock
Only valid for the lock and unlock events: Returns the lock object corresponding to the current operation dbms_xevent.getLock(ev IN XDBRepositoryEvent)
RETURN XDBLock;
TBD
 
getLockMode
Returns the lock's mode (shared or exlusive) dbms_xevent.getLockMode(lk in XDBLock)
RETURN PLS_INTEGER;
TBD
 
getLockType
Returns the lock's type (write or read-write) dbms_xevent.getLockType(lk in XDBLock)
RETURN PLS_INTEGER;
TBD
 
getName
Returns the string representation of the path dbms_xevent.getName(path IN XDBPath)
RETURN VARCHAR2;
See Demo At Page Bottom
 
getNext
Returns the next handler in the list dbms_xevent.getNext(hl IN XDBHandlerList)
RETURN XDBHandler;
TBD
 
getNFSNodeId
Returns the RAC node id if this is an NFSv4 lock. Otherwise null dbms_xevent.getNFSNodeId(lk in XDBLock)
RETURN RAW;
TBD
 
getOldResource
Returns the XDBResource object before the current operation started. Applies only to Update events. Other events return an error. dbms_xevent.getOldResource(ev IN XDBRepositoryEvent)
RETURN DBMS_XDBResource.XDBResource;
TBD
 
getOpenAccessMode
Only valid for the open event. Returns the access mode for the open operation, which could be one of: OPEN_ACCESS_READ, OPEN_ACCESS_WRITE, or OPEN_ACCESS_READ_WRITE dbms_xevent.getOpenAccessMode(
ev IN XDBRepositoryEvent)
RETURN PLS_INTEGER;
TBD
 
getOpenDenyMode
Only valid for the open event. Returns the deny mode for the open operation, which could be one of: OPEN_DENY_NONE, OPEN_DENY_READ, or OPEN_DENY_READ_WRITE dbms_xevent.getOpenDenyMode(
ev IN XDBRepositoryEvent)
RETURN PLS_INTEGER;
TBD
 
getOutputStream
Only valid for the Render event. Returns the output BLOB in which the handler can write the rendered data. dbms_xevent.getOutputStream(ev IN XDBRepositoryEvent)
RETURN BLOB;
TBD
 
getParameter
Returns the value of a request or session-specific parameter. Currently, the only parameters supported are "Accept", "Accept-Language", "Accept-Charset" and "Accept-Encoding" dbms_xevent.getParameter(
ev  IN XDBRepositoryEvent,
key IN VARCHAR2)
RETURN VARCHAR2;
TBD
 
getParent
Returns the parent of the target resource dbms_xevent.getParent(ev IN XDBRepositoryEvent)
RETURN dbms_XDBResource.XDBResource;
TBD
 
getParentName
Returns the link's parent folder's name dbms_xevent.getParentName(link IN XDBLink)
RETURN VARCHAR2;
TBD
 
getParentOID
Return the link's parent folder's OID dbms_xevent.getParentOID(link IN XDBLink)
RETURN RAW;
TBD
 
getParentPath
Returns the parent's path dbms_xevent.getParentPath(
path  IN XDBPath,
level IN PLS_INTEGER)
RETURN XDBPath;
TBD
 
getPath
Returns the XDBPath object representing the path of the resource for which the event was fired. From this object, functions are provided to get the different path segments dbms_xevent.getPath(ev IN XDBRepositoryEvent)
RETURN XDBPath;
See Demo At Page Bottom
 
getResource
Returns the target resource for the operation that executed the current event. For a link* or unlink* event, this returns the resource that the link is pointing to. For a create event, this method returns the resource that is being created. dbms_xevent.getResource(
ev IN XDBRepositoryEvent)
RETURN DBMS_XDBResource.XDBResource;
See Demo At Page Bottom
 
getSchema
Returns the schema of the handler's source dbms_xevent.getSchema(handler IN XDBHandler)
RETURN VARCHAR2;
TBD
 
getSource
Returns the name of the Java class, PL/SQL package or object type implementing the handler dbms_xevent.getSource(handler IN XDBHandler)
RETURN VARCHAR2;
TBD
 
getUpdateByteCount
Returns the byte count of an inconsistent-update event if the current operation is a byte-range write dbms_xevent.getUpdateByteCount(
ev IN XDBRepositoryEvent)
RETURN NUMBER;
TBD
 
getUpdateByteOffset
Only valid for the inconsistent-update event. If the current operation is a byte-range write, it returns the byte offset at which the range begins dbms_xevent.getUpdateByteOffset(
ev IN XDBRepositoryEvent)
RETURN NUMBER;
TBD
 
getXDBEvent
Converts an XDBRepositoryEvent object to an XDBEvent type dbms_xevent.getXDBEvent(ev IN XDBRepositoryEvent)
RETURN XDBEvent;
See Demo At Page Bottom
 
isNULL
RETURNS - TRUE if the input argument is null
Overload 1
dbms_xevent.isNull(ev IN XDBEvent)
RETURN BOOLEAN;
TBD
Overload 2 dbms_xevent.isNull(repev IN XDBRepositoryEvent)
RETURN BOOLEAN;
TBD
Overload 3 dbms_xevent.isNull(hl IN XDBHandlerList)
RETURN BOOLEAN;
TBD
Overload 4 dbms_xevent.isNull(handler IN XDBHandler)
RETURN BOOLEAN;
TBD
Overload 5 dbms_xevent.isNull(path IN XDBPath)
RETURN BOOLEAN;
TBD
Overload 6 dbms_xevent.isNull(link IN XDBLink)
RETURN BOOLEAN;
TBD
Overload 7 dbms_xevent.isNull(lk IN XDBLock)
RETURN BOOLEAN;
TBD
 
REMOVE
Removes the named handler from the list dbms_xevent.remove(
hl      IN XDBHandlerList,
handler IN XDBHandler);
TBD
 
setRenderPath
Only valid for the Render event. Specifies the path of the resource that contains the rendered contents. Do not be call after the stream returned by getOutputStream() is written to or after setRenderStream() is called or an exception will be raised dbms_xevent.setRenderPath(
ev   IN XDBRepositoryEvent,
path IN VARCHAR2);
TBD
 
setRenderStream
Only valid for the Render event. Sets the BLOB from which the rendered contents can be read. Do not call after the stream returned by getOutputStream() is written to or after setRenderPath() is called or an exception will be raise dbms_xevent.setRenderStream(
ev   IN XDBRepositoryEvent,
istr IN BLOB);
TBD
 
Demo
The demonstration at right is taken from the Oracle Online documentation and is repeated here as it was very difficult to locate. Formatting was added to improve readability.

Also added AUTHID to the package header because apparently they don't teach that in Oracle development. LOL
CREATE OR REPLACE PACKAGE appcatg_evt_pkg1 AUTHID CURRENT_USER AS
 PROCEDURE handlePreUnlinkIn (eventObject DBMS_XEVENT.XDBRepositoryEvent);
 PROCEDURE handlePostLinkIn (eventObject DBMS_XEVENT.XDBRepositoryEvent);
END appcatg_evt_pkg1;
/

CREATE OR REPLACE PACKAGE BODY appcatg_evt_pkg1 AS
----------------------------------------------------
PROCEDURE handlePreUnlinkIn(eventObject DBMS_XEVENT.XDBRepositoryEvent) AS
 XDBResourceObj DBMS_XDBRESOURCE.XDBResource;
 ResDisplayName VARCHAR2(100);
 ResPath        VARCHAR2(1000);
 ResOwner       VARCHAR2(1000);
 ResDeletedBy   VARCHAR2(1000);
 XDBPathobj     dbms_xevent.XDBPath;
 XDBEventobj    dbms_xevent.XDBEvent;
 SeqChar        VARCHAR2(1000);
 LinkName       VARCHAR2(10000);
 ResType        VARCHAR2(100);
 LinkFolder     VARCHAR2(100);
BEGIN
  XDBResourceObj := dbms_xevent.getResource(eventObject);
  ResDisplayName := dbms_xdbresource.getDisplayName(XDBResourceObj);
  ResOwner       := dbms_xdbresource.getOwner(XDBResourceObj);
  XDBPathobj     := dbms_xevent.getPath(eventObject);
  ResPath        := dbms_xevent.getName(XDBPathObj);
  XDBEventobj    := dbms_xevent.getXDBEvent(eventObject);
  ResDeletedBy   := dbms_xevent.getCurrentUser(XDBEventobj);

  BEGIN
    SELECT XMLCast(
             XMLQuery(
               'declare namespace ns = "http://xmlns.oracle.com/xdb/XDBResource.xsd";
               /ns:Resource/ns:ContentType'
               PASSING r.RES RETURNING CONTENT) AS VARCHAR2(100))
    INTO ResType
    FROM PATH_VIEW r
    WHERE r.PATH=ResPath;
  EXCEPTION
    WHEN OTHERS THEN NULL;
  END;

  IF ResType = 'text/xml' THEN LinkFolder := '/public/app/XML-TXT/'; END IF;
  IF ResType = 'image/gif' THEN LinkFolder := '/public/app/IMG/'; END IF;
  IF ResType = 'application/octet-stream' THEN LinkFolder := '/public/app/FOLDER/'; END IF;

  dbms_xdb.deleteResource(LinkFolder || ResDisplayName);
END handlePreUnlinkIn;
----------------------------------------------------
PROCEDURE handlePostLinkIn(eventObject DBMS_XEVENT.XDBRepositoryEvent) AS
 XDBResourceObj dbms_xdbresource.XDBResource;
 ResDisplayName VARCHAR2(100);
 ResPath        VARCHAR2(1000);
 ResOwner       VARCHAR2(1000);
 ResDeletedBy   VARCHAR2(1000);
 XDBPathobj     dbms_xevent.XDBPath;
 XDBEventobj    dbms_xevent.XDBEvent;
 SeqChar        VARCHAR2(1000);
 LinkName       VARCHAR2(10000);
 ResType        VARCHAR2(100);
 LinkFolder     VARCHAR2(100);
BEGIN
  XDBResourceObj := dbms_xevent.getResource(eventObject);
  ResDisplayName := dbms_xdbresource.getDisplayName(XDBResourceObj);
  ResOwner       := dbms_xdbresource.getOwner(XDBResourceObj);
  XDBPathobj     := dbms_xevent.getPath(eventObject);
  ResPath        := dbms_xevent.getName(XDBPathObj);
  XDBEventobj    := dbms_xevent.getXDBEvent(eventObject);
  ResDeletedBy   := dbms_xevent.getCurrentUser(XDBEventobj);

  SELECT XMLCast(
           XMLQuery(
             'declare namespace ns = "http://xmlns.oracle.com/xdb/XDBResource.xsd";
             /ns:Resource/ns:ContentType'
             PASSING r.RES RETURNING CONTENT) AS VARCHAR2(100))
  INTO ResType
  FROM PATH_VIEW r
  WHERE r.PATH=ResPath;

  IF ResType = 'text/xml' THEN LinkFolder := '/public/app/XML-TXT'; END IF;
  IF ResType = 'image/gif' THEN LinkFolder := '/public/app/IMG'; END IF;
  IF ResType = 'application/octet-stream' THEN LinkFolder := '/public/app/FOLDER'; END IF;

  dbms_xdb.link(ResPath, LinkFolder, ResDisplayName);
END handlePostLinkIn;
----------------------------------------------------
END;
/

Related Topics
Built-in Functions
Built-in Packages
DBMS_XDB
DBMS_XDBREPOS
DBMS_XDBRESOURCE
What's New In 12cR1
What's New In 12cR2

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2017 Daniel A. Morgan All Rights Reserved