Transaction Independence in Oracle8i

Transaction Independence in Oracle8i

In a nested procedure environment, I have often felt the need to isolatethe transactions of the child/called procedure from the parent/calling procedure’s transactions. Until Oracle8i, it used to be a cumbersome process. Oracle8i has introduced a new feature called “autonomous transactions,” which help isolate the changes made in the current transaction independent of the calling transaction context. Common usage of autonomous transactions would be in error logging mechanism, applying commits, and rollbacks in the database triggers, and also for building reusable application components or cartridges.

To make a PL/SQL block autonomous, simply include the following statement in the declaration section:


Anonymous PL/SQL blocks, database functions, stored procedures, packaged procedures, methods of SQL object type, and database triggers can be declared as autonomous transactions.

The code sample shown below explains the use of autonomous transaction for error logging. Let’s say procedure Proc1 invokes procedure ErrorLog:

 procedure Proc1(p_empid varchar2, p_empname)  is begin  insert into emp(empid,empname) values(p_empid, p_empname);exception   when others then    errorlog(SQLCODE,SQLERRM);    raise_application_error(-20001, 'Data could not be inserted into Emp table.');end;procedure ErrorLog(v_errcode varchar2, v_errmsg varchar2) is   PRAGMA AUTONOMOUS_TRANSACTION;begin  insert into errorlog_table(errorcode, errormsg) values(v_errcode,v_errmsg);  commit;end;

In this example, the error message is committed into errorlog_table even though the calling transaction is rolled back.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as