473,790 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autonomous procedure falsely committing?

Hi guys - I have a weird condition here I'm trying to get resolution
on, and unfortunately I'm not getting anywhere with my friends at
Oracle. I'm hoping it's something simple, or at the very least it's a
documented bug that I can simply reference and move on.

The following code and session output (I think) documents a condition
where a procedure marked for an automomous commit is commiting an
INSERT over a database link that is outside of its transactional
boundry. In a nutshell, my INSERT is committing when it shouldn't,
*only* in situations where I have an autonomous transaction, *and* I
have an error handler that doesn't gracefully rollback the
transaction. My test case:

--setup only - the actual test run is further down
create table cca_autonomous_ commit_test_9i (
id number,
creation_date date
)
/

create or replace procedure autonomous_inse rt is

PRAGMA AUTONOMOUS_TRAN SACTION;

begin

--insert into local database table
insert into cca_autonomous_ commit_test_9i values ( 1 ,sysdate );
commit;

end;
/

create or replace procedure dloomis_test

is

begin

--reset environment
delete from cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s;
delete from cca_autonomous_ commit_test_9i;

commit;

--insert over database link.
insert into cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s values (
1, sysdate );

--call my autonomous procedure, which should *NOT* commit the record
above
autonomous_inse rt;

--raise error, for testing purposes only
raise NO_DATA_FOUND;

end;
/

--the test output
Session 1:

--Execute dloomis_test, which should throw no_data_found by design:

SQL> exec dloomis_test
BEGIN dloomis_test; END;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "APPS.DLOOMIS_T EST", line 20
ORA-06512: at line 1

Session 2 - everything looks ok:

SQL> select count(*) from cca_autonomous_ commit_test_9i;

COUNT(*)
----------
1

SQL> select count(*) from
cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s;

COUNT(*)
----------
0
Now, if I Control-C out of session 1, the 8i record is commited
somehow:

Session 2:

SQL> select count(*) from
cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s;

COUNT(*)
----------
1

This is not always reproducable, but if you run the test several times
over you will get the results above. My question is - how is the 8i
record being commited, if the only commit being issued is in the
autonomous procedure? I realize an explicit ROLLBACK command in the
WHEN OTHERS block will fix the issue, but I'd still like an answer on
why this happens under the above condition.

Thanks a bunch -

Dan Loomis
IT Engineer, Cisco Systems
Jul 19 '05 #1
1 4488
dl*****@gmail.c om (Dan Loomis) wrote in message news:<e2******* *************** ****@posting.go ogle.com>...
Hi guys - I have a weird condition here I'm trying to get resolution
on, and unfortunately I'm not getting anywhere with my friends at
Oracle. I'm hoping it's something simple, or at the very least it's a
documented bug that I can simply reference and move on.

The following code and session output (I think) documents a condition
where a procedure marked for an automomous commit is commiting an
INSERT over a database link that is outside of its transactional
boundry. In a nutshell, my INSERT is committing when it shouldn't,
*only* in situations where I have an autonomous transaction, *and* I
have an error handler that doesn't gracefully rollback the
transaction. My test case:

--setup only - the actual test run is further down
create table cca_autonomous_ commit_test_9i (
id number,
creation_date date
)
/

create or replace procedure autonomous_inse rt is

PRAGMA AUTONOMOUS_TRAN SACTION;

begin

--insert into local database table
insert into cca_autonomous_ commit_test_9i values ( 1 ,sysdate );
commit;

end;
/

create or replace procedure dloomis_test

is

begin

--reset environment
delete from cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s;
delete from cca_autonomous_ commit_test_9i;

commit;

--insert over database link.
insert into cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s values (
1, sysdate );

--call my autonomous procedure, which should *NOT* commit the record
above
autonomous_inse rt;

--raise error, for testing purposes only
raise NO_DATA_FOUND;

end;
/

--the test output
Session 1:

--Execute dloomis_test, which should throw no_data_found by design:

SQL> exec dloomis_test
BEGIN dloomis_test; END;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "APPS.DLOOMIS_T EST", line 20
ORA-06512: at line 1

Session 2 - everything looks ok:

SQL> select count(*) from cca_autonomous_ commit_test_9i;

COUNT(*)
----------
1

SQL> select count(*) from
cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s;

COUNT(*)
----------
0
Now, if I Control-C out of session 1, the 8i record is commited
somehow:

Session 2:

SQL> select count(*) from
cca_autonomous_ commit_test_8i@ xxcts_sjoe_ccai s;

COUNT(*)
----------
1

This is not always reproducable, but if you run the test several times
over you will get the results above. My question is - how is the 8i
record being commited, if the only commit being issued is in the
autonomous procedure? I realize an explicit ROLLBACK command in the
WHEN OTHERS block will fix the issue, but I'd still like an answer on
why this happens under the above condition.

Thanks a bunch -

Dan Loomis
IT Engineer, Cisco Systems


Dan, the execution of an anonymous transaction as part of a
distributed transaction in 8i is unsupported. This is stated in the
8i manuals and normally results in an error being raised. Version 9+
does support performing an anonymous transaction as part of a
distributed transaction, but I would expect this to work only when
connecting to another version 9+ database.

It would appear each database is following the rules for its version.

IMHO -- Mark D Powell --
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7891
by: Sam | last post by:
Guys, I have a question regarding oracle. I have a stored procedure executing a number of statements including delete , select and lots of inserts in one big procedure and main transaction I have a stored procedure sp_log_action with a PRAGMA AUTONOMOUS TRANSACTION defined which is called after each statement in the main stored procedure(this writes the event to a table).
0
6934
by: Brent Mondoux | last post by:
Hey everyone, I have a set of stored procedures that call each other to perform a set of tasks. I have decided to do this for database performance reasons rather than doing it from a ColdFusion page (and to prevent timeouts, etc.) These stored procedures run every night and handle scheduled tasks in a complex system.
7
9228
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into a table (c) re-queries another table using a subquery which references the inserted table (correlated or not)
1
1881
by: _link98 | last post by:
On Linux or Solaris with UDB 8.2.2, can an SQL/PL stored-procedure use two-phase-commit with nicknames and if DB2 provides the Transaction-manager? i.e. in the same transaction, can an SQL/PL procedure update a local table and also update a nicknamed-table (in another database on the same hostname), before committing ? Is this possible, or must I have a CLI procedure and not use nicknames?
4
3681
by: Daniel Daoust | last post by:
Hi, knowing that "autonomous transaction" (Oracle concept of) are not yet implemented in PostgreSQL, has anyone found a work-around. I need to preserve database states from a potential rollback and then log them inside database tables. What about: 1) using memory structures to hold the info, then commit to the database just before exit (after the
5
14111
by: dilippanda | last post by:
Hi Experts, I want to know what is the use of pragma autonomous transaction in PL/SQL. In which condition should we use this? Please guide me with an example. Thanks, Dilip
1
1685
AdusumalliGopikumar
by: AdusumalliGopikumar | last post by:
Where we can't use Autonomous transaction?
1
754
by: Dan Loomis | last post by:
Hi guys - I have a weird condition here I'm trying to get resolution on, and unfortunately I'm not getting anywhere with my friends at Oracle. I'm hoping it's something simple, or at the very least it's a documented bug that I can simply reference and move on. The following code and session output (I think) documents a condition where a procedure marked for an automomous commit is commiting an INSERT over a database link that is outside...
7
3469
by: Serge Rielau | last post by:
John Hopfield wrote: If you were Pinocchio I'd say: "Listen to the grasshopper". Locks have be held until the transaction commits. Ideally your application should do this. But you add the COMMIT in your procedure as well if it encapsulates a complete transaction. In addition (not as a substitute) you also want to look at setting DB2_SKIP_INSERTED. Generally a good feature. Cheers Serge
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.