触发器问题 当表a中插入一条数据时。把插入的数据存入b表中 怎么写呀????求帮助
3个回答
展开全部
交给我吧,这是个最基础的触发器,假设A表的2个字段为ID,name,B表与A表字段相同
create or replace trigger AB_DML_TGR
after insert
on A
for each row
begin
if inserting then
insert into B
values
(:new.ID,
:new.name);
DBMS_OUTPUT.PUT_LINE('新数据已保存到B中');
end if;
end;
create or replace trigger AB_DML_TGR
after insert
on A
for each row
begin
if inserting then
insert into B
values
(:new.ID,
:new.name);
DBMS_OUTPUT.PUT_LINE('新数据已保存到B中');
end if;
end;
追问
create trigger MyDocFileTrg
on WCMAPPENDIX
for insert,update
as
declare @FILENAME nvarchar(255),
@CRUSER nvarchar(50)
begin
select @FILENAME=APPFILE,@CRUSER=CRUSER from inserted
INSERT INTO XWCMMyDocFileTrg (APPFILE,CRUSER) VALUES (@FILENAME,@CRUSER)
end
我也搞定了
展开全部
帮忙看一下这个触发器,要求:当cl_bm中添加一条记录,同时在zd_yz语句中写一条记录,下面触发器没生效
CREATE TRIGGER TR_CLBM_CR
ON CL_BM
FOR INSERT
AS
INSERT
ZD_YZ(LX, BM, DH, MC, DJ, JL, YLDW, JLDW, GG, FYLB, CLLB, STATE, ZXBZ, GBBM, PRINTMC)
SELECT top 1
1, BM, DH, MC, DJ, 1, DW, DW, GG, FYLB = 71, CLLB=0, STATE = 0, ZXBZ = 0 , GBBM, PRINTMC=MC
FROM CL_BM where lb like '2%' and bm not in (select bm from inserted)
CREATE TRIGGER TR_CLBM_CR
ON CL_BM
FOR INSERT
AS
INSERT
ZD_YZ(LX, BM, DH, MC, DJ, JL, YLDW, JLDW, GG, FYLB, CLLB, STATE, ZXBZ, GBBM, PRINTMC)
SELECT top 1
1, BM, DH, MC, DJ, 1, DW, DW, GG, FYLB = 71, CLLB=0, STATE = 0, ZXBZ = 0 , GBBM, PRINTMC=MC
FROM CL_BM where lb like '2%' and bm not in (select bm from inserted)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询