日期:2014-05-16  浏览次数:21092 次

oracel触发器问题,值之间的传递。在线等.... 急~!~!~
create or replace trigger trigger_Eis_role
after insert on user
for each row DECLARE organId char(32);
select organ_id into organId from emp_employee where user_id = username;--user_id 是唯一的 后面我要用到organId, 这种方式能不能将查询出来的organ_id的值传递给organId如果查询出来是空的时候会报错?
在线等.... 急



------解决方案--------------------
先判断
declare 
..
cou int :=0;
...
select count(1) into cou from emp_employee where user_id = username;
if cou<>0
select organ_id into organId from emp_employee where user_id = username;
end if;

------解决方案--------------------
OR
SQL code
create or replace trigger trigger_Eis_role
after insert on user
for each row 
DECLARE 
organId char(32);
select organ_id into organId from emp_employee where user_id = username;
EXCEPTION WHEN No_Data_Found THEN 
   organId:='';