Dashboard > ApacheDS Addons > ... > Developer's Guide > Triggers and Stored Procedures
Triggers and Stored Procedures
Added by Alex Karasulu, last edited by Alex Karasulu on Nov 16, 2005
Labels: 
(None)


ApacheDS Triggers will provide DB Triggers like functionality for LDAP.

Reading material

RFCs and Drafts

X.501

  • Section 4: Directory Administrative Model (pages 28-33)
  • Section 5: Model of Directory Administrative and Operational Information (pages 34-40)

Past work

Related work

Functionality discussion

A trigger initiates when an Event occurs and executes a set of Operations at some Relative Time when some predefined Conditions are satisfied.

For our case:

  • An Event can be an LDAP operation like Add, ModifyRDN, etc.
  • An Operation can be an LDAP operation like Add, ModifyRDN, etc.
  • A Relative Time may be just AFTER or BEFORE the Event time. (INSTEADOF which means the exact Event time and so Event operation replacement will also be considered.)
  • Contiditons may be a filter expression that needs to be satisfied for the Entry being considered.

Implementation discussion

Triggers will be implemented using the same infrastructure as the ACI implementation which is Subentry subsystem. Both of prescriptive triggers and entry triggers will be valid. We will need to define ABNF syntaxes for all LDAP operations to be able to specify them in trigger operational attributes' values.

Some notes from Oracle documentation

Overview of Writing Procedures and Functions in Java

Functions and procedures are named blocks that encapsulate a sequence of statements.
They are like building blocks that you can use to construct modular, maintainable
applications. You write these named blocks and then define them by using the
loadjava command or SQL CREATE FUNCTION, CREATE PROCEDURE, or CREATE
PACKAGE statements. These Java methods can accept arguments and are callable from:

  • SQL CALL statements
  • Embedded SQL CALL statements
  • PL/SQL blocks, subprograms, and packages
  • DML statements (INSERT, UPDATE, DELETE, and SELECT)
  • Oracle development tools such as OCI, Pro*C/C++, and Oracle Developer
  • Oracle Java interfaces such as JDBC, SQLJ statements, CORBA, and Enterprise
    Java Beans
  • Method calls from object types

Overview of Writing Database Triggers in Java

A database trigger is a stored procedure that Oracle Database invokes ("fires")
automatically when certain events occur, for example, when a DML operation
modifies a certain table. Triggers enforce business rules, prevent incorrect values from
being stored, and reduce the need to perform checking and cleanup operations in each
application.

Why Use Java for Stored Procedures and Triggers?

  • Stored procedures and triggers are compiled once, are easy to use and maintain,
    and require less memory and computing overhead.
  • Network bottlenecks are avoided, and response time is improved. Distributed
    applications are easier to build and use.
  • Computation-bound procedures run faster in the server.
  • Data access can be controlled by letting users have only stored procedures and
    triggers that execute with their definer's privileges instead of invoker's rights.
  • PL/SQL and Java stored procedures can call each other.
  • Java in the server follows the Java language specification and can use the SQLJ
    standard, so that databases other than Oracle Database are also supported.
  • Stored procedures and triggers can be reused in different applications as well as
    different geographic sites.
Java Code in DIT (ApacheDS Addons)
Trigger Implementation Notes (ApacheDS Addons)

Site running on a free Atlassian Confluence Open Source Project License granted to Safehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators