Test autonomous transactions

Source: Internet
Author: User

SQL> Create Table Test (T number );

The table has been created.

SQL>

SQL> Create or replace view BB as select * from test;

The view has been created.

SQL>

Use an alternative trigger and apply the autonomous transaction in it (this trigger can only be applied to the view)
SQL> show err
No error.
SQL> Create or replace trigger AA
2 instead of insert or delete or update on bb
3 declare
4 Pragma autonomous_transaction;
5 begin
6 if inserting then
7 insert into test values (: New. t );
8 commit;
9 elsif updating then
10 Update Test
11 set T =: New. t
12 where T =: Old. t;
13 commit;
14 else
15 Delete from test
16 where T =: Old. t;
17 commit;
18 end if;
19
20 -- commit;
21 end;
22/

Trigger created

SQL> show err
No error.
SQL>

SQL> select * from test;

Unselected row

SQL>

SQL> Create or replace trigger aaa
2 before insert or delete or update on Test
3 begin
4 raise_application_error (-20000, 'Could insert/update/delete directly .');
5 end;
6/

Trigger created

Used time: 00: 00: 00.40
SQL>

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.