Use of alternative triggers

Source: Internet
Author: User

When you need to create a trigger for a view to process business logic or data flows, you can use an alternative trigger to perform operations on view-related tables.

SQL> Create Table user_info (ID number, name varchar2 (200); table created. SQL> insert into user_info values (1, 'dinya '); 1 row created. SQL> commit; Commit complete. SQL> Create Table skill (ID number, skill varchar2 (300), user_id number); table created. SQL> insert into skill values (1, 'type', 1); 1 row created. SQL> commit; Commit complete. SQL> Create or replace view user_skills as select. ID,. name, B. skill from user_info A, skill B where. id = B. user_id; view created. SQL> select * From user_skills; ID name skill --------------- -------------------------------- when 1 dinya typed SQL> Update user_skills t set T. skill = 'Surfing the net'; update user_skills t set T. skill = 'internet' * error at line 1: ORA-01779: cannot modify a column which maps to a non key-preserved table SQL> Create or replace trigger user_skills_update 2 instead of update on user_skills 3 for each row 4 Begin 5 update skill set skill =: new. skill where user_id =: Old. ID; 6 end; 7/trigger created. SQL> Update user_skills t set T. skill = 'Surfing net' where T. id = 1; 1 row updated. SQL> commit; Commit complete. SQL> select * From skill; Id skill user_id ----------------- ----------------------------------------------------------------------- 1 SQL> # dinya

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.