ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling
complimentary technical Workshops on Database Security for the first 30
Oracle Database customers located anywhere in North America, EMEA, LATAM, or
APAC that send an email to
asra_us@oracle.com. Request a Workshop for
your organization today.
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));
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;
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;
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;
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;
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;
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);
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);
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;
/
BEGIN
SELECT XMLCast(
XMLQuery(
'declare namespace ns = "https://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;
SELECT XMLCast(
XMLQuery(
'declare namespace ns = "https://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;
/