1. TRG_CONTENTS_CREATE
/**
author : 정우창
e-mail : ultra102@nate.com
created date : 2014-11-04
project name : CKMC
description : 컨텐츠등록후 발생되는 트리거
return value :
TBL_CONTENTS 테이블에 데이터가 등록된 이후 발생되는 TRIGGER
TBL_CONTENTS_HISTORY에 데이터 등록
**/
CREATE TRIGGER TRG_CONTENTS_CREATE
ON TBL_CONTENTS
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRAN
BEGIN TRY
DECLARE @idx BIGINT
DECLARE @postMember NUMERIC(10)
SELECT
@idx = PK_contentsIdx,
@postMember=FK_PostMember_MEMBER
from inserted WITH(NOLOCK)
exec SP_MASTER_CONTENTS_HISTORY_CREATE @idx, 'I', @postMember, '새로운 글을 등록했습니다.'
END TRY
BEGIN CATCH
if @@TRANCOUNT > 0
ROLLBACK TRAN
END CATCH
if @@TRANCOUNT > 0
COMMIT TRAN
SELECT @idx
END
댓글 영역