Brian Aker wrote:
Hi!
On May 4, 2009, at 7:37 AM, Jim Starkey wrote:
I ignored SQL standard triggers and implemented Java-based triggers
instead.
What did the DDL look like for this?
Adding C++ triggers right now would be easy (and from the interface
Monty Taylor could tie a half a dozen other languages, including Java).
I don't believe that un-sandboxed user code should ever be allowed in a
database system. I did that Interbase and felt guilty for 25 years.
What should it look like though?
Cheers,
-Brian
BTW I find triggers for cache invalidation to be a pretty handy feature.
Syntax:
CREATE TRIGGER <name> [ FOR ] <table name> [ <option> ]...
where <option> is one of
[ BEFORE | AFTER ] INSERT
[ BEFORE | AFTER ] UPDATE
[ BEFORE | AFTER ] DELETE
[ BEFORE | AFTER ] COMMIT
POSITION <position>
ACTIVE
INACTIVE
CLASS <trigger class>
where <position> specified firing order and <trigger class> the name of
a trigger class, which let an application suspend or reactivate a class
of triggers within a session. Very use.
An example of a trigger definition:
upgrade trigger EVENT_NOTIFICATION for EVENTS
before insert before update after delete active position 10
using 'netfrasoft.modules.Calendar.eventNotification'
The corresponding trigger:
public static void eventNotification (NfsConnection connection,
Record oldVersion, Record newVersion, int type)
throws SQLException
{
if (newVersion == null)
{
eventDeleted (connection, oldVersion);
return;
}
int oldStatus = newVersion.getInt("notification_status");
int eventStatus;
if (oldVersion == null)
eventStatus = EVENT_SCHEDULED;
else
{
int change = getChange (oldVersion, newVersion);
eventStatus = Math.max(change, oldStatus);
}
if (newVersion.getString("pending").equals("Y"))
{
newVersion.setInt("notification_status", eventStatus);
return;
}
String subject = null;
switch (eventStatus)
{
case EVENT_UNCHANGED:
return;
case EVENT_SCHEDULED:
break;
case EVENT_RESCHEDULED:
subject = "Event Rescheduled";
break;
case EVENT_MOVED:
subject = "Event Moved";
break;
}
eventInserted (connection, newVersion, subject);
newVersion.setInt("notification_status", EVENT_UNCHANGED);
}
--
Jim Starkey
President, NimbusDB, Inc.
978 526-1376
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp