/* ============================================================================
   FUNCTION_MODULE – TRIGGER
   Voraussetzung: Tabelle [_meta].[TBDD_CFG_FUNCTION_MODULE] und Prozeduren existieren
   ============================================================================ */

USE [DD_IIM];
GO

CREATE OR ALTER TRIGGER [_meta].[TBDD_CFG_FUNCTION_MODULE_IO_INS]
ON [_meta].[TBDD_CFG_FUNCTION_MODULE]
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AFTER INSERT
AS
BEGIN ATOMIC WITH
(
    TRANSACTION ISOLATION LEVEL = SNAPSHOT,
    LANGUAGE = N'us_english'
)
    IF CONTEXT_INFO() IS NULL OR CONTEXT_INFO() <> 0x544244445F46554E4354494F4E5F4D4F44554C45
    BEGIN
        THROW 51101, 'Direktes INSERT auf [_meta].[TBDD_CFG_FUNCTION_MODULE] ist nicht erlaubt. Bitte Prozedur [_meta].[PRDD_UPSERT_FUNCTION_MODULE] verwenden.', 1;
    END;
END;
GO

CREATE OR ALTER TRIGGER [_meta].[TBDD_CFG_FUNCTION_MODULE_IO_UPD]
ON [_meta].[TBDD_CFG_FUNCTION_MODULE]
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AFTER UPDATE
AS
BEGIN ATOMIC WITH
(
    TRANSACTION ISOLATION LEVEL = SNAPSHOT,
    LANGUAGE = N'us_english'
)
    IF CONTEXT_INFO() IS NULL OR CONTEXT_INFO() <> 0x544244445F46554E4354494F4E5F4D4F44554C45
    BEGIN
        THROW 51102, 'Direktes UPDATE auf [_meta].[TBDD_CFG_FUNCTION_MODULE] ist nicht erlaubt. Bitte Prozedur [_meta].[PRDD_UPSERT_FUNCTION_MODULE] verwenden.', 1;
    END;
END;
GO

CREATE OR ALTER TRIGGER [_meta].[TBDD_CFG_FUNCTION_MODULE_IO_DEL]
ON [_meta].[TBDD_CFG_FUNCTION_MODULE]
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AFTER DELETE
AS
BEGIN ATOMIC WITH
(
    TRANSACTION ISOLATION LEVEL = SNAPSHOT,
    LANGUAGE = N'us_english'
)
    IF CONTEXT_INFO() IS NULL OR CONTEXT_INFO() <> 0x544244445F46554E4354494F4E5F4D4F44554C45
    BEGIN
        THROW 51103, 'Direktes DELETE auf [_meta].[TBDD_CFG_FUNCTION_MODULE] ist nicht erlaubt. Bitte Prozedur [_meta].[PRDD_DELETE_FUNCTION_MODULE] verwenden.', 1;
    END;
END;
GO
