数据插入之前更新字段值

来源:互联网 发布:python os 复制 编辑:程序博客网 时间:2024/05/21 02:51

在一个表报警信息中插入记录,但是没有x,y值信息,其中的x,y值要根据记录中的现场警力编号到gps警员表中查取xy值,然后付给当前记录,再进行插入。

 

 

create or replace trigger getxy before insert
on SDGA.报警信息 for each row
declare
   xx number:=0;
   yy number:=0;
begin

 

 select gps警员.x into xx from gps警员 where gps警员.警力编号 = :NEW.现场警力编号;
 
 select gps警员.y into yy from gps警员 where gps警员.警力编号 = :NEW.现场警力编号;
 
 :NEW.x := xx;
 :NEW.y := yy;
 
end;

原创粉丝点击