是A表有数据。打错了两个字。不好意思。Oracle触发器实现表中有数据就插到另一张表中,(这个数据 70
是A表有数据。打错了两个字。不好意思。Oracle触发器实现表中有数据就插到另一张表中,(这个数据是定时器获取的)。然后再将此表中数据删除,有大神吗?最好有实例说明,急。...
是A表有数据。打错了两个字。不好意思。Oracle触发器实现表中有数据就插到另一张表中,(这个数据是定时器获取的)。然后再将此表中数据删除,有大神吗?最好有实例说明,急。
展开
展开全部
create table aaa (
a_id number(10) primary key not null,
a_name varchar(32),
a_date date not null
);
create table bbb (
b_id number(10) primary key not null,
a_id number(10),
b_name1 varchar(32) not null,
b_name2 varchar(32) not null,
b_name3 varchar(32) not null
);
create table A11 (
a11_id number(10) primary key not null,
a_name varchar(32),
a_date date not null
);
create table B22 (
bb_id number(10) primary key not null,
a11_id number(10),
bb_name1 varchar(32) not null,
bb_name2 varchar(32) not null,
bb_name3 varchar(32) not null
);
create table C33 (
cc_id number(10) primary key not null,
a11_id number(10),
cc_name1 varchar(32) not null,
cc_name2 varchar(32) not null,
cc_name3 varchar(32) not null
);
create or replace procedure demo_1(v_id in number) as
v_sup varchar2(2000);
begin
select a_id into v_sup from aaa a where a_id=
(select distinct b2.a11_id from B22 b2 where b2.a11_id = (select a11_id from A11 where a11_id = v_id)) ;
insert into bbb
(b_id, a_id, b_name1, b_name2, b_name3)
select c3.cc_id, c3.a11_id, c3.cc_name1, c3.cc_name2, c3.cc_name3
from C33 c3
where c3.cc_id = v_sup;
update bbb b set (b.b_name1,b.b_name2)=(select bb_name1,bb_name2 from B22 b2
where b2.a11_id=v_id and b2.bb_name3=(select b_name3 from bbb where a_id=v_id) )
where b.a_id=v_id;
commit;
end;
这是我之前做过的一个存储过程实现 update和insert的功能 你看看改下 希望能帮到你
a_id number(10) primary key not null,
a_name varchar(32),
a_date date not null
);
create table bbb (
b_id number(10) primary key not null,
a_id number(10),
b_name1 varchar(32) not null,
b_name2 varchar(32) not null,
b_name3 varchar(32) not null
);
create table A11 (
a11_id number(10) primary key not null,
a_name varchar(32),
a_date date not null
);
create table B22 (
bb_id number(10) primary key not null,
a11_id number(10),
bb_name1 varchar(32) not null,
bb_name2 varchar(32) not null,
bb_name3 varchar(32) not null
);
create table C33 (
cc_id number(10) primary key not null,
a11_id number(10),
cc_name1 varchar(32) not null,
cc_name2 varchar(32) not null,
cc_name3 varchar(32) not null
);
create or replace procedure demo_1(v_id in number) as
v_sup varchar2(2000);
begin
select a_id into v_sup from aaa a where a_id=
(select distinct b2.a11_id from B22 b2 where b2.a11_id = (select a11_id from A11 where a11_id = v_id)) ;
insert into bbb
(b_id, a_id, b_name1, b_name2, b_name3)
select c3.cc_id, c3.a11_id, c3.cc_name1, c3.cc_name2, c3.cc_name3
from C33 c3
where c3.cc_id = v_sup;
update bbb b set (b.b_name1,b.b_name2)=(select bb_name1,bb_name2 from B22 b2
where b2.a11_id=v_id and b2.bb_name3=(select b_name3 from bbb where a_id=v_id) )
where b.a_id=v_id;
commit;
end;
这是我之前做过的一个存储过程实现 update和insert的功能 你看看改下 希望能帮到你
2016-03-23
展开全部
这个你得建插入、删除和更新三种触发器。
create trigger tr_in_选课表 on 选课表
FOR INSERT
as
update 课程表 set 选课人数=选课人数+1 where 课程编号=(select 课程编号 from inserted)
go
--删除的,删除时那就要减1
create trigger tr_del_选课表 on 选课表
FOR DELETE
AS
update 课程表 set 选课人数 = 选课人数-1 where 课程编号=(select 课程编号 from deleted)
GO
create trigger tr_in_选课表 on 选课表
FOR INSERT
as
update 课程表 set 选课人数=选课人数+1 where 课程编号=(select 课程编号 from inserted)
go
--删除的,删除时那就要减1
create trigger tr_del_选课表 on 选课表
FOR DELETE
AS
update 课程表 set 选课人数 = 选课人数-1 where 课程编号=(select 课程编号 from deleted)
GO
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询