Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE [PRITPB]
- GO
- /****** Object: Trigger [dbo].[T_PRJ_AtulizaObra_Historico] Script Date: 07-06-2023 15:04:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE TRIGGER [dbo].[T_PRJ_AtulizaObra_Historico] ON [dbo].[Historico]
- FOR INSERT, UPDATE
- AS
- -- Só deve ser executado se os campos que são necessários ao COP foram modificadados
- IF UPDATE(ObraID)
- BEGIN
- SET NOCOUNT ON
- DECLARE @Cabec UNIQUEIDENTIFIER
- DECLARE XCURSOR CURSOR LOCAL FOR
- SELECT id FROM INSERTED
- OPEN XCURSOR
- FETCH NEXT FROM XCURSOR INTO @Cabec
- UPDATE c SET c.CDU_ObraIdAnalise=dbo.F_IDObra_Fixed_Optimized(c.ObraId)
- FROM
- Historico c
- WHERE
- c.id = @Cabec
- CLOSE XCURSOR
- DEALLOCATE XCURSOR
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement