Sample Delete Trigger

This topic contains the text of an existing delete trigger, SSSE_CONT_INFO_T1, and two drop-trigger statements that precede it. This trigger resides in the ssse_triggers_mssql.sql file, which is intended for Siebel implementations that use a Microsoft SQL Server database. The trigger operates when a record is deleted from table S_CONTACT_INFO. For more information about delete triggers, see About Creating Custom Delete Triggers and Creating Custom Delete Triggers.

Note: In this sample text, database_owner serves as a placeholder for the name of the database user who owns the table that the trigger modifies (in this case, the table is S_CONTACT_INFO). Leading hyphens indicate a comment for a Microsoft SQL Server database script.
-- Delete of S_CONTACT_INFO 
--
--
-- Drop the 7.8 trigger name
IF exists (select name from sysobjects

	where name = 'S_CONTACT_INFO_T1'

		and type = 'TR')

	drop trigger database_owner.S_CONTACT_INFO_T1

	GO

	IF exists (select name from sysobjects

		where name = 'SSSE_CONT_INFO_T1'

		and type = 'TR')

	drop trigger database_owner.SSSE_CONT_INFO_T1

	GO

	CREATE TRIGGER database_owner.SSSE_CONT_INFO_T1
	on database_owner.S_CONTACT_INFO
	FOR delete
	AS

	insert into database_owner.S_SD_SYNC_INFO ( ROW_ID,


		CREATED,
		CREATED_BY,
		LAST_UPD,
		LAST_UPD_BY,
		MODIFICATION_NUM,
		CONFLICT_ID,
		SEBL_DOMAIN_IDEN, 
		SEBL_ROW_IDEN, 
		SEBL_USER_ID, 
		OPERATION_TYPE, 
		DB_LAST_UPD,
		DB_LAST_UPD_SRC)

	select NULL,

		GETUTCDATE(),
		'PIMSI',
		GETUTCDATE(),
		'PIMSI',
		0,
		'0', 
		'PIMSI Intermediate Business Contact', 
		dd.TARGET_PER_ID, 
		dd.OWNER_PER_ID, 
		'delete', 
		GETUTCDATE(),
		'PIMSI'

	from deleted dd

GO

The following facts might be useful to you as you create new delete triggers based on existing triggers such as the preceding sample:

  • Delete triggers can also be used to operate when records are updated. SSSE_CONTACT_PIM3 and SSSE_ACT_EMP_PIM3 are examples of existing triggers of this type.

  • The list of columns inserted by each delete-trigger is the same for each record that is created in the S_SD_SYNC_INFO table. In the preceding sample, the list of columns begins with ROW_ID and ends with DB_LAST_UPD_SRC.