zhouweifeng
ҽ
л
ҵBlog
¹鵵...
·...
Ķ...
ͳ...
վ...
Դ
===========================================================
INSTEAD OF(zt)
===========================================================

ܱ֤Ψһͼǿֱ£Ҫôʵ


ͼĶ壺ͼԴֻһݱͼΪͼͼԴǶݱͼΪͼ
ɸͼĶ壺ھ˵ĸУͼֻģ޸ġORACLE 8iϰ汾ͼû趨With Read OnlyͼǿԸµģͼIJֱдݱС
ôͼԴǶݱͼʵֿɸͼԴ߱Чʡ

1 ǰ
ͼĶ壺ͼԴֻһݱͼΪͼͼԴǶݱͼΪͼ
ɸͼĶ壺ھ˵ĸУͼֻģ޸ġORACLE 8iϰ汾ͼû趨With Read OnlyͼǿԸµģͼIJֱдݱС
ôͼԴǶݱͼʵֿɸͼԴ߱Чʡ

2 ɸͼӦ÷Χ
ڳʵֹУὫƷšλͻϢȵȴ洢ڶݱ۵ݡⵥݵȴIDͿָϸϢ
ڲѯͼϣǽҪȷϵɣ¼棬ҪʵֶϢͬ༭ʱšҪӦøָı̷ʵû
ɸͼǰ̵̨Ĺǰ̨FORMΪöɸͼһҵݱݵĴ洢߼ں̨ͼInstead of С

3 ɸͼĺ̨ʵ
ͼInstead Of TriggerTriggerжݴ洢߼ʵ˶ɸͼ<ӵļѵ㣬ķޱȼ򵥵>ʵ£
3.1 ݱ
--===================================================
--Ա
--===================================================
Drop Table t1;
Drop Table t2;
create table t1
( t11 numeric(28),t12 varchar2(20));
create table t2
( t11 numeric(28),t22 varchar2(20));
3.2 ͼ
--===================================================
--ͼ
--===================================================
create Or Replace view t as
select T1.t11 f1 ,T1.t12 f2 ,T2.t22 f3
from T1,T2
Where T1.t11=T2.t11;
3.3 ͼ
--===================================================
--ͼ
--===================================================
Create Or Replace Trigger Trg_InsUpdDel_t
Instead Of Insert or update or delete
on t
for each row
Declare
begin
If Inserting Then
Insert Into t1 (t11,t12) Values (:New.f1,:New.f2);
Insert Into t2 (t11,t22) Values (:New.f1,:New.f3);
elsif Updating Then
Update t1 set t11=:New.f1,t12=:New.f2 where t11=:New.f1;
Update t2 set t11=:New.f1,t22=:New.f3 where t11=:New.f1;
elsif Deleting then
Delete from t1 where t11=:Old.f1;
Delete from t2 where t11=:Old.f1;
End if;
end;
˼ʵֶɸͼĶ幤ҿʹInsertDeleteUpdateSQLһ¡
3.4 ݿ̨ע
ͼʹCreate Or Replace View...±󣬸ôͻᱻǣҲˡԴҼǵ±ɸͼ֮Ҫ´䴥

4 ɸͼǰ̨ʵּע
4.1 ʵ
ԴУݿԴΪɸͼʵǰ̨趨
ȻעʵӦùоͻء
4.2 FORMǰ̨ע
4.2.1 ɸͼУ<:Where t1.t11=t2.t11(+)>FORMжݿԡFORMʾͼ¡
4.2.2 SQLͼʹUnionDistinctǰ̨FORM޷ʵָ¹ܡ

zhouwf0726 :2007.12.12 14:30 ::: ( oracle ) ::Ķ:(124) :: (0) :: (0)



ڴ

ƺ

ַѡ

ҳѡ

authimage