USE [LAB_DB]
GO

/****** Object:  Trigger [dbo].[CallIfSelectContact]    Script Date: 3/7/2568 17:09:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:  Sukit
-- Create date: 2024-10-04
-- Description: Call If Select Contact
-- =============================================
CREATE TRIGGER [dbo].[CallIfSelectContact]
   ON  [dbo].[tbl_lab_information_Critical] 
   AFTER UPDATE
AS 
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;

    -- Insert statements for trigger here
    DECLARE @LN NVARCHAR(20);
 DECLARE @Test_code NVARCHAR(10);
 DECLARE @Result datetime;
 DECLARE @Type NVARCHAR(1);
 DECLARE @ResultTime datetime;
 DECLARE @Call NVARCHAR(100);

 SET @LN = (SELECT LN FROM INSERTED);
 SET @Type = (SELECT Action_Type FROM INSERTED);
 SET @Test_code = (SELECT Test_Code FROM INSERTED);
 SET @ResultTime = (SELECT Result_Time FROM INSERTED);
 SET @Call = (SELECT Action_Comment FROM INSERTED);
 
 if @Type = 'N' and @Call <> ''
 begin
  update tbl_lab_information_Critical 
  set  [Action_Type] = 'Y'
  ,[Action_Time] = GETDATE()
  where LN = @LN and Test_Code = @Test_code and Result_Time = @ResultTime
 end
END


GO


Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: