Hi
I have made a trigger that fires when deleting rows. However it returns an empty recordset, and it is not supposed to. How do I change that?
CREATE TRIGGER [Log_Delete_Definition_Source] ON [dbo].[Definition_Source]
FOR DELETE
AS
SET NOCOUNT ON
DECLARE @concept_identifier int,
@page varchar (15),
@source_identifier varchar (20),
@language_symbol char (2),
@note nvarchar (1000)
DECLARE definition_source_cursor CURSOR FOR SELECT concept_identifier, page, source_identifier, language_symbol FROM Deleted INNER JOIN Definition ON Deleted.definition_identifier = Definition.definition_identifier
OPEN definition_source_cursor
-- Perform the first fetch.
FETCH NEXT FROM definition_source_cursor INTO @concept_identifier, @page, @source_identifier, @language_symbol
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
-- This is executed as long as the previous fetch succeeds.
SET @note = 'Source deleted for ' + @language_symbol + ' definition.' + CHAR(13) + 'Source: ' + @source_identifier
IF @page <> ''
BEGIN
SET @note = @note + CHAR(13) + 'Page: ' + @page
END
EXEC Trigger_Insert_Concept_Terminology_Management_Transaction 6, @concept_identifier, @note
FETCH NEXT FROM definition_source_cursor
END
CLOSE definition_source_cursor
DEALLOCATE definition_source_cursor
I have made a trigger that fires when deleting rows. However it returns an empty recordset, and it is not supposed to. How do I change that?
CREATE TRIGGER [Log_Delete_Definition_Source] ON [dbo].[Definition_Source]
FOR DELETE
AS
SET NOCOUNT ON
DECLARE @concept_identifier int,
@page varchar (15),
@source_identifier varchar (20),
@language_symbol char (2),
@note nvarchar (1000)
DECLARE definition_source_cursor CURSOR FOR SELECT concept_identifier, page, source_identifier, language_symbol FROM Deleted INNER JOIN Definition ON Deleted.definition_identifier = Definition.definition_identifier
OPEN definition_source_cursor
-- Perform the first fetch.
FETCH NEXT FROM definition_source_cursor INTO @concept_identifier, @page, @source_identifier, @language_symbol
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
-- This is executed as long as the previous fetch succeeds.
SET @note = 'Source deleted for ' + @language_symbol + ' definition.' + CHAR(13) + 'Source: ' + @source_identifier
IF @page <> ''
BEGIN
SET @note = @note + CHAR(13) + 'Page: ' + @page
END
EXEC Trigger_Insert_Concept_Terminology_Management_Transaction 6, @concept_identifier, @note
FETCH NEXT FROM definition_source_cursor
END
CLOSE definition_source_cursor
DEALLOCATE definition_source_cursor