oracle触发器请教
表 a 字段分别为 id name
表 b 字段分别为 id b_id b_a_id与a表中字段id是多对一关系
表 c 字段分别为 id c_id c_b_id与b表中字段id是多对一关系
怎么样在删除表a中的记录时同时删除表b中的记录,同时删除表c中的内容我用这种方面可以,但是b_id是从页面传递的参数,不是固定值,应该怎么写?CREATE OR REPLACE TRIGGER a
Before delete on b
DECLARE
tmpNum int;
Begin
tmpNum :=0;
select count(*) as count into tmpNum from b where b_id = 6;
if tmpNum > 0 then
Delete from b where b_a_id = 6;
end if;
end;
表 a 字段分别为 id name
表 b 字段分别为 id b_id b_a_id与a表中字段id是多对一关系
表 c 字段分别为 id c_id c_b_id与b表中字段id是多对一关系
怎么样在删除表a中的记录时同时删除表b中的记录,同时删除表c中的内容我用这种方面可以,但是b_id是从页面传递的参数,不是固定值,应该怎么写?CREATE OR REPLACE TRIGGER a
Before delete on b
DECLARE
tmpNum int;
Begin
tmpNum :=0;
select count(*) as count into tmpNum from b where b_id = 6;
if tmpNum > 0 then
Delete from b where b_a_id = 6;
end if;
end;
解决方案 »
- occi.h文件是什么
- 求一个参数游标的问题
- 怎么查看oracle归档日志dbf格式的内容呢?
- 用SQLLOADER将INFORMIX倒出的表倒入到ORACLE时遇到的字符问题,麻烦各位帮我看看
- 這個語句爲什麽報錯 麻煩各位~
- oracle9i安装完后默认的连接数据库的用户名和密码是什么啊?
- 大家帮帮忙。
- 客户机与oracle数据服务器连接问题?
- 安装oracle9的时候出现问题
- oracle中 if exists (select) update ...else ...insert 怎样写?
- DB定义为NUMBER(10,7)时,文件固定项目10位,使用Sql*Loader导入数据问题
- 关于 数据类型 RAW 的问题
Before delete on a
DECLARE
--tmpNum int;
Begin
--select count(*) as count into tmpNum from b where b_id = 6;
delete from b where b.b_id = :old.b_id;
delete from c where c.b_id = :old.b_id;
end;这样就可以拉!