创建一个触发器,使其代替delete语句,从而可以删除表中的内容
展开全部
CREATE TRIGGER [dbo].[TrigDeleteArea]
ON [dbo].[travel.Area]
AFTER DELETE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @AreaID int
select @AreaID =[area.AreaId] from inserted
delete [travel.line] where [line.AreaId]=@AreaID
-- Insert statements for trigger here
END
GO
ON [dbo].[travel.Area]
AFTER DELETE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @AreaID int
select @AreaID =[area.AreaId] from inserted
delete [travel.line] where [line.AreaId]=@AreaID
-- Insert statements for trigger here
END
GO
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这是我们的考试题o(∩_∩)o...:(正确答案)
CREATE OR REPLACE TRIGGER CHECK_TIME
BEFORE
UPDATE OR INSERT OR DELETE
ON EMP
BEGIN
IF (TO_CHAR(SYSDATE,'DY') IN ('SAT','SUN'))
OR TO_CHAR(SYSDATE,'HH24')< '08'
OR TO_CHAR(SYSDATE,'HH24')>='18' THEN
RAISE_APPLICATION_ERROR(-20500,'非法时间修改表错误!');
END IF;
END;
CREATE OR REPLACE TRIGGER CHECK_TIME
BEFORE
UPDATE OR INSERT OR DELETE
ON EMP
BEGIN
IF (TO_CHAR(SYSDATE,'DY') IN ('SAT','SUN'))
OR TO_CHAR(SYSDATE,'HH24')< '08'
OR TO_CHAR(SYSDATE,'HH24')>='18' THEN
RAISE_APPLICATION_ERROR(-20500,'非法时间修改表错误!');
END IF;
END;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
需求不明,打回重写
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询