两张表table1, table2结构一样,结构如下
xm, sex, age
当我改变table1的age时,把table1更改之前的数据插入到table2,做个备份。
xm, sex, age
当我改变table1的age时,把table1更改之前的数据插入到table2,做个备份。
解决方案 »
- oracle自定义function如果异常返回值是什么?
- 求助求助!oracle监听。
- 查询
- 如何判断数据库中是否有数据存在?
- 根据两个日期字符串取记录问题
- 一个关于oracle的存储过程该怎么调用啊,为什么我总是出错?
- 关于 PL/SQL 数组 清空(初始化)
- 请教:想根据一个DATETIME时间字段得出在一天内的上午、下午、晚上的记录!!请大下帮忙啊!在线等!!!
- 请教,重装Oracle要做哪些,主要注册表要删除什么
- 如何在存储过程的LOOP中临时创建视图,用完后删除?
- 【在线等,急】请教一个数据更新的问题,高手们都进来看一下吧!!!
- 为什么我进入sql*plus后无论输入什么命令,都显示缓冲区无可运行的程序
xm varchar2(20),
sex varchar2(20),
age varchar2(20));
create table table_info_temp(
xm varchar2(20),
sex varchar2(20),
age varchar2(20));declare
cur_update sys_refcursor;
temp_date table_info_temp%rowtype;
begin
open cur_update for select * from table_info where sex='1';
loop
exit when cur_update%notfound;
fetch cur_update into temp_date;
insert into table_info_temp values temp_date;
end loop;
close cur_update;
end;
after insert or update or delete on table_info
for each row
declare
cur_update sys_refcursor;
temp_date table_info_temp%rowtype;
begin
open cur_update for select * from table_info where sex='1';
loop
exit when cur_update%notfound;
fetch cur_update into temp_date;
insert into table_info_temp values temp_date;
end loop;
close cur_update;
end;
你連new, old都沒引用到
after UPDATE ON table_info
FOR EACH ROW
BEGIN
if :old.age <> :new.age then
insert into table_info_temp values(:old.xm, :old.sex, :old.age);
END IF;
END;