AdsDDCreateTrigger

Advantage Client Engine

Adds a new trigger to the data dictionary.

Syntax

UNSIGNED32 AdsDDCreateTrigger( ADSHANDLE hDictionary, UNSIGNED8 *pucName,

UNSIGNED8 *pucTableName, UNSIGNED32 ulTriggerType,

UNSIGNED32 ulEventTypes, UNSIGNED32 ulContainerType,

UNSIGNED8 *pucContainer, UNSIGNED8 *pucFunctionName,

UNSIGNED32 ulPriority, UNSIGNED8 *pucComments,

UNSIGNED32 ulOptions );

Parameters

hDictionary (I)

A data dictionary connection.

pucName (I)

The name of the trigger to be created.

pucTableName (I)

The name of the table the trigger will fire on.

ulTriggerType (I)

The type of trigger to create. This value can be ADS_TRIGTYPE_BEFORE, ADS_TRIGTYPE_INSTEADOF, ADS_TRIGTYPE_CONFLICTON, or ADS_TRIGTYPE_AFTER.

ulEventTypes (I)

The kind of event the trigger should fire on. This value can be ADS_TRIGEVENT_INSERT, ADS_TRIGEVENT_UPDATE, or ADS_TRIGEVENT_DELETE.

ulContainerType (I)

The kind of container the trigger lives in. This value can be ADS_TRIG_WIN32DLL, ADS_TRIG_COM, or ADS_TRIG_SCRIPT.

pucContainer (I)

The container. If the container type is ADS_TRIG_WIN32DLL this value should be the path and dll name (or linux path and shared object name). If the container type is ADS_TRIG_COM this value should be the ProgID of a COM object or a .NET assembly. If the container type is ADS_TRIG_SCRIPT, this should be a pointer to the trigger script statements.

pucFunctionName (I)

The name of the function to call inside the container. This value is ignored if the container type is ADS_TRIG_SCRIPT.

ulPriority (I)

Firing order priority if multiple triggers of the same type exist on a table (for example, multiple AFTER triggers).

pucComments (I)

Optional description of the trigger.

ulOptions (I)

This is a bit field for defining the options for creating the trigger. The options can be OR’ed together. The options are:

ADS_TRIGOPTIONS_DEFAULT: Default options. Trigger values tables will be passed to the trigger (__old and __new tables) and will include memo and blob data.

 

ADS_TRIGOPTIONS_WANT_MEMOS_AND_BLOBS: Currently the same as ADS_TRIGOPTIONS_DEFAULT.

 

ADS_TRIGOPTIONS_WANT_VALUES: Trigger values tables will be passed to the trigger, but will not include memo or blob data.

 

ADS_TRIGOPTIONS_NO_VALUES: Trigger values tables will not be passed to the trigger.

ADS_TRIGOPTIONS_NO_TRANSACTION: Implicit transaction will not be started for this trigger.

Remarks

AdsDDCreateTrigger can only be called by the database administrator.

Trigger creation does not verify library or .NET assembly existence. If a trigger is defined on a library or assembly that does not exist, a run-time error will occur when the trigger is executed.

Statements inside script triggers are validated for syntactical correctness only. If any semantic errors exist, a run-time error will occur when the trigger is executed.

If a trigger container is in use, and modifications are made to a trigger definition (including trigger addition or deletion), the changes will not take effect until all users who have used a trigger in that container disconnect from the database.

Currently trigger creation and deletion will not affect tables already opened by the server. For example, if table1 is opened by active clients, and the administrator adds a new trigger to table1, the trigger will not activate until all active users have closed table1 and it has been re-opened.

See Triggers for detailed trigger information.

Example

ulRetVal = AdsDDCreateTrigger( hConn,

"MyTrigger",

"mytable",

ADS_TRIGTYPE_AFTER,

ADS_TRIGEVENT_INSERT,

ADS_TRIG_WIN32DLL,

"x:\data\AdsTriggers.dll",

"myfunction",

1 /* priority */,

"my first trigger ",

ADS_TRIGOPTIONS_DEFAULT );

See Also

AdsDDRemoveTrigger