Thanks for the question, Kaare.
Asked: August 24, 2016 - 1:42 pm UTC
Last updated: August 31, 2016 - 9:24 am UTC
Version: 11
Viewed 1000+ times
update view1 set viewcol1 = '01-07-2012' where id=1;
SQL> desc view1 Name Null? Type ----------------------------- -------- -------------------- ID NUMBER VIEWCOL1 VARCHAR2(4)
create or replace view view1 as select id, cast(substr ( col1, 7 ) as varchar2(20)) as viewcol1 from table1; create or replace trigger trigger1 instead of update on view1 for each row declare c_col1 varchar2 ( 100 ) ; begin c_col1 := :new.viewcol1; if length ( :new.viewcol1 ) = 4 then c_col1 := '01-01-'||:new.viewcol1; else c_col1 := :new.viewcol1; end if; update table1 t set t.col1 = c_col1 where t.id = :old.id; end; / desc view1 update view1 set viewcol1 = '01-07-2012' where id=1; select * from table1; ID COL1 ---------- ---------- 1 01-07-2012 2 25-08-2016
Kaare Friis-Christensen, September 05, 2016 - 9:51 am UTC
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library