oracle - Create trigger for view to edit table's data -


i ask wrong trigger view. view:

create view produkt_view  select * produkt; 

trigger:

create or replace trigger dawka_zeruj instead of update on produkt_view declare begin     if(:old.dawka = :new.dawka)         update produkt_view set dawka_l_p = null, dawka_j_p = null bloz12=:old.bloz12;     end if; end; 

after executing sql developer asks paramters.. tought :old, :new paramters update seems not.. wrong?

ps. want set 2 columns: "dawka_l_p" , "dawka_j_p" null if change column "dawka" on update. thats all. bloz12 primary key.

ps2. dawka varchar2 column should if(:old.dawka :new.dawka) still not work.

definition of table:

create table produkt  (   bloz7 number  , bloz12 number  , nazwa varchar2(100 byte)  , nazwa_miedz varchar2(100 byte)  , dawka varchar2(70 byte)  , dawka_zloz varchar2(1 byte)  , dawka_l_p float(126)  , dawka_j_p varchar2(50 byte)  , dawka_l_r float(126)  , dawka_j_r varchar2(50 byte)  , dawka_l_n float(126)  , dawka_j_n varchar2(50 byte)  , postac varchar2(70 byte)  , opakowanie varchar2(70 byte)  , podmiot_odp varchar2(100 byte)  , podmiot_odp_kraj varchar2(40 byte)  , nazwa_pelna varchar2(310 byte)  , opak_najm_zarej varchar2(70 byte)  , temp_od float(126)  , temp_do float(126)  , ceny_id number  , wytworca_id number  )  logging  tablespace "users"  pctfree 10  initrans 1  storage  (    initial 65536    next 1048576    minextents 1    maxextents 2147483645    buffer_pool default  );  alter table produkt add constraint produkt_ceny_urzedowe foreign key (   ceny_id  ) references ceny_urzedowe (   id  ) enable;  alter table produkt add constraint produkt_wytworca foreign key (   wytworca_id  ) references wytworca (   id  ) enable; 

as stated in comments, must specify full update statement both cases.

create or replace trigger dawka_zeruj instead of update on produkt_view     declare  begin    if(:old.dawka <> :new.dawka)       -- change :new values, re-use      :new.dawka_l_p = null;      :new.dawka_j_p = null;   end if;    -- update can done in cases table.   update produkt       set dawka_l_p = :new.dawka_l_p        , dawka_j_p = :new.dawka_j_p        , dawka     = :new.dawka     bloz12=:old.bloz12;  end; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -