create or replace trigger sy befor insert on 表4 for each row
begin
select classNeme into :new.className1 from 表2
where classid =
(select classid from 表3
where addressid = :new.addressid and rownum <= 1); select classNeme into :new.className2 from 表2
where classid =
(select classid from 表3
where addressid = :new.addressid and rownum <= 1
and classid <> :new.className1); EXCEPTION
WHEN OTHERS THEN
null;
end;
begin
select classNeme into :new.className1 from 表2
where classid =
(select classid from 表3
where addressid = :new.addressid and rownum <= 1); select classNeme into :new.className2 from 表2
where classid =
(select classid from 表3
where addressid = :new.addressid and rownum <= 1
and classid <> :new.className1); EXCEPTION
WHEN OTHERS THEN
null;
end;
解决方案 »
- secureCRT 的操作记录如何能一连上就开始自动保存啊
- 遇到问题了,在线等,大拿们帮忙sqlldr
- 我用了管道表函数,编译时ORACLE报00600错误
- oracle 50W数据,查询要好几分钟,怎么优化数据库?
- 请教oracle8问题
- 备份问题: 我在用exp 备份数据库里面的某个表时, 竟然返回的信息说: table does not exists , 但是此表又确实属于我当前登陆用户的表
- oracle里用sql语句select查询出现“无法在本地管理的表空间创建临时段”是什么原因?
- 请问ORACLE的过程PROCEDURE中是不是不能用嵌套子查询??!!
- 怎样在sql plus中终止一个查询语句。
- 一个非常迫切得问题-关于LINUX下ORACLE删除一个日志文件后无法启动得问题?(急)
- 高分求救!!!ora-12154: TNS: 无法处理服务名 急,在线等待
- 请问oracle数据库多内码问题。
before insert on 表4
for each row
begin
select ClassName into
select (select ClassName from 表2 b where b.ClassID=C.ClassID) INTO :new.ClassName1 from 表3 c where AddressID=:new.AddressID;
end;
/
good luck!DECLARE
n_temp number;
class_name1 YourType;
class_name2 YourType;
CURSOR class_name IS
SELECT a.ClassName FROM 表2 a,表3 b
WHERE a.ClassId=b.ClassId and b.AddressId=:new.AddressId;
begin
if inserting then
n_temp:=1
for RC in class_name loop
if n_temp=3 then
exit;
end if;
if n_temp=1 then
class_name1:=RC.ClassName;
end if;
if n_temp=2 then
class_name2:=RC.ClassName;
end if; n_temp:=n_temp+1;
end loop;
ClassName1:=class_name1;
ClassName2:=class_name2;
end if;
end;