473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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_insert is

PRAGMA AUTONOMOUS_TRANSACTION;

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_ccais;
delete from cca_autonomous_commit_test_9i;

commit;

--insert over database link.
insert into cca_autonomous_commit_test_8i@xxcts_sjoe_ccais values (
1, sysdate );

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

--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_TEST", 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_ccais;

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_ccais;

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 4456
dl*****@gmail.com (Dan Loomis) wrote in message news:<e2**************************@posting.google. 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_insert is

PRAGMA AUTONOMOUS_TRANSACTION;

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_ccais;
delete from cca_autonomous_commit_test_9i;

commit;

--insert over database link.
insert into cca_autonomous_commit_test_8i@xxcts_sjoe_ccais values (
1, sysdate );

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

--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_TEST", 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_ccais;

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_ccais;

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
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...
0
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...
7
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...
1
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...
4
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...
5
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
AdusumalliGopikumar
by: AdusumalliGopikumar | last post by:
Where we can't use Autonomous transaction?
1
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...
7
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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...
0
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...

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.