473,756 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Oracle PRAGMA AUTONOUMOUS_TRA NSACTION equivalent in DB2?

Does DB2 have anything equivalent to Oracle's PRAGMA AUTONOMOUS_TRAN SACTION
that allows a stored procedure to BEGIN, COMMIT or ROLLBACK a totally
independent transaction while possibly (but not necessarily) nested inside a
different ("parent") transaction?

I need to write (INSERT) data to an EVENT_LOG table and COMMIT that INSERT
without COMMIT'ing any other work in progress in the transaction my
usp_write_event _log might be called from within.
Sep 7 '06 #1
3 3512
Fred Morrison wrote:
Does DB2 have anything equivalent to Oracle's PRAGMA
AUTONOMOUS_TRAN SACTION that allows a stored procedure to BEGIN, COMMIT or
ROLLBACK a totally independent transaction while possibly (but not
necessarily) nested inside a different ("parent") transaction?

I need to write (INSERT) data to an EVENT_LOG table and COMMIT that INSERT
without COMMIT'ing any other work in progress in the transaction my
usp_write_event _log might be called from within.
No, there is nothing like that in DB2. However, you could use an external
proceduce that establishes a new connection to the DBMS (and thus, a new
session/transaction context).

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 7 '06 #2
I always wanted to ask following question:

DB2 v8.2.1, Windows.
Try this;
---
declare global temporary table session.t (i int) with replace on commit
preserve rows not logged on rollback preserve rows@
create table logger_test(i int)@
create procedure logger
(
cmd varchar(255)
, tmp varchar(255)
)
language sql
begin atomic
declare stmt varchar(255);
set stmt='insert into '||tmp||' values (1)';
execute immediate stmt;
set stmt='insert into logger_test values (1)';
execute immediate stmt;
execute immediate cmd;
end@
call logger('execute me, please!!!', 'session.t')@
select i i_session from session.t@
select i i_logger_test from logger_test@
---
This small example shows that we can rollback changes in a cataloged
table but preserve changes in session table if error occured in atomic
block.
But it works despite of documentation
(http://publib.boulder.ibm.com/infoce...n/r0003272.htm)
:
---
Notes:
Instantiation and Termination:
....
When a rollback operation terminates a unit of work or a savepoint in
P, and that unit of work or savepoint includes a modification to
SESSION.T, then if NOT LOGGED was specified, the rollback includes the
operation DELETE from SESSION.T, else the changes to T are undone.
---
Is this behavior a feature or... ?
If this Works As Designed, then, Fred, you can use this technique for
logging.

Sincerely,
Mark B.
Fred Morrison wrote:
Does DB2 have anything equivalent to Oracle's PRAGMA
AUTONOMOUS_TRAN SACTION that allows a stored procedure to BEGIN, COMMIT or
ROLLBACK a totally independent transaction while possibly (but not
necessarily) nested inside a different ("parent") transaction?

I need to write (INSERT) data to an EVENT_LOG table and COMMIT that INSERT
without COMMIT'ing any other work in progress in the transaction my
usp_write_event _log might be called from within.

No, there is nothing like that in DB2. However, you could use an external
proceduce that establishes a new connection to the DBMS (and thus, a new
session/transaction context).

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 7 '06 #3
4.****@mail.ru wrote:
I always wanted to ask following question:

DB2 v8.2.1, Windows.
Try this;
---
declare global temporary table session.t (i int) with replace on commit
preserve rows not logged on rollback preserve rows@
create table logger_test(i int)@
create procedure logger
(
cmd varchar(255)
, tmp varchar(255)
)
language sql
begin atomic
declare stmt varchar(255);
set stmt='insert into '||tmp||' values (1)';
execute immediate stmt;
set stmt='insert into logger_test values (1)';
execute immediate stmt;
execute immediate cmd;
end@
call logger('execute me, please!!!', 'session.t')@
select i i_session from session.t@
select i i_logger_test from logger_test@
---
This small example shows that we can rollback changes in a cataloged
table but preserve changes in session table if error occured in atomic
block.
But it works despite of documentation
(http://publib.boulder.ibm.com/infoce...n/r0003272.htm)
:
---
Notes:
Instantiation and Termination:
...
When a rollback operation terminates a unit of work or a savepoint in
P, and that unit of work or savepoint includes a modification to
SESSION.T, then if NOT LOGGED was specified, the rollback includes the
operation DELETE from SESSION.T, else the changes to T are undone.
---
Is this behavior a feature or... ?
If this Works As Designed, then, Fred, you can use this technique for
logging.
For a bug it's using quite explicit syntax language :-)
This feature was added to support SQL procedure tracing
http://www-128.ibm.com/developerwork...dm-0409rielau/

I have submitted a doc bug report using the feedback button on the DB2 9
Information Center.

You are correct that this feature is well suited for for event logging.
For auditing things get a bit more tricky.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Sep 7 '06 #4

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

Similar topics

4
9340
by: Mark Wilson CPU | last post by:
A colleague has written a prototype program in PHP, using a MySQL database. It's a relatively simple app, with a restricted set of mysql commands used (see below). The MySQL DB is being replaced with an Oracle DB (same schema). My plan 1) globally replace the few mysql commands with intermediate equivalents (such as myDB_connect for mysql_connect) 2) those central functions would then (for now) call the original mysql function to prove...
38
25113
by: Mike | last post by:
No flame wars, please! We're planning a move from a non-relational system to a relational system. Our choices have been narrowed to Oracle and DB2. Since we're moving from non-relational to relational, then we're not currently using any relational-type operators. So I expect the end result to use simple, SQL standard commands and queries. The question: At the SQL standard level is there any
125
15496
by: Rhino | last post by:
One of my friends, Scott, is a consultant who doesn't currently have newsgroup access so I am asking these questions for him. I'll be telling him how to monitor the answers via Google Newsgroup searches. Scott has heard a lot of hype about DB2 and Oracle and is trying to understand the pros and cons of each product. I'm quite familiar with DB2 but have never used Oracle so I can't make any meaningful comparisons for him. He does not have...
133
9090
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in comparison to oracle? We are seriously considering migrating our multi-processor oracle system to mysql to save on licensing costs, and would need several features that mysql may or may not have:
11
3204
by: Mark A | last post by:
Here is Mark Townsend's (Oracle Product Manager) explanation and justification for posting in the DB2 newsgroup, as posted on the Oracle newsgroup, and my response: "Mark Townsend" <markbtownsend@comcast.net> wrote in message > > By an large you will find that they > all fall into 1 of 3 categorires. > > 1) Explaining how Oracle does something when somebody asks how to do the
2
18385
by: gimme_this_gimme_that | last post by:
Assuming data is being stored in a DB2 TIMESTAMP what is the equivalent of Oracle's to_date function : to_date('03/04/2005','MM/DD/YYYY') It's OK if MM/DD/YYYY is the only supported format. Thanks.
6
3967
by: Shri | last post by:
Can anybody tell me where i can find a detailed document on #pragma .... --shri
8
2106
by: Steve Richter | last post by:
Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler provided in IBM's ILE C compiler? http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.iseries.pgmgd.doc/cpprog436.htm What #pragma cancel_handler does is provide the building blocks for try .... finally code block in a C function. I am researching the degree of difficulty involved in porting ILE C code from an IBM AS400 to GNU C.
5
7234
by: jonceramic | last post by:
Hi All, I started developing in Access, and people took notice and so we're starting to migrate into our corporate's bigger Oracle system. I'll still be using my developed Access front ends, but will be migrating my back ends to Oracle ODBC. 1. Does anyone have recommendations for books or web resources for general rules/guidelines/help on doing this? I haven't found a good
0
9325
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
9930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9716
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
9716
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
8569
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7116
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
4996
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
3676
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
3
2542
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.