graphql-engine/server/src-rsr/mssql_update_trigger.sql.shakespeare

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
467 B
Plaintext
Raw Normal View History

CREATE OR ALTER TRIGGER #{qualifiedTriggerName}
ON #{qualifiedTableName}
AFTER UPDATE
AS
BEGIN
DECLARE @json NVARCHAR(MAX)
SET @json = (
SELECT #{oldDeliveryColsSQLExp}, #{newDeliveryColsSQLExp}
FROM DELETED
JOIN INSERTED
ON #{primaryKeyJoinExp}
#{listenColumnExp}
FOR JSON PATH
)
insert into hdb_catalog.event_log (schema_name,table_name,trigger_name, payload)
select '#{schemaName}','#{tableName}','#{triggerNameText}', value from OPENJSON (@json)
END