|
Hi,
Even if this is true, why if I simply remove "exec sql select..." from
TESTPGM program, those transaction don't run under commit, even with BEGIN
ATOMIC in trigger.
I can clearly see in the journal that even if all triggers have ATOMIC,
not all transaction runs under commit.
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Charles
Wilt
Sent: Friday, February 14, 2020 1:11 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Transaction runs under commit while it should not
Yes it does...
"In the BEGIN clause, you can specify the keyword ATOMIC. This keyword
indicates that if an error occurs in the compound statement, all SQL
statements in the compound statement are rolled back."
https://www.redbooks.ibm.com/abstracts/sg248326.html?Open
Charles
On Thu, Feb 13, 2020 at 5:00 PM Steve Richter <stephenrichter@xxxxxxxxx>
wrote:
doesn;t BEGIN ATOMIC implicitly mean commitment control?--
On Thu, Feb 13, 2020 at 6:22 PM Filip Drzewiecki via RPG400-L <
rpg400-l@xxxxxxxxxxxxxxxxxx> wrote:
Hi,in
I have a commitment control issue which we can't resolve and in my
opinion, it should not work in that way.
Even if there is some wrong logic in below code, I can't understand
why some transaction runs under commit while they should not.
The problem here is that update on TESTTABLE run under commit but
actual trigger has commit=*none. Next time it run's properly without
commit and
another loop it run under commit again(in TESTPGM I do updates inand
loop
it looks every run it behave differently).because
The weirdest thing is that it works just fine if I'll simply remove
exec sql select... from program TESTPGM After I've added exec sql
select... to pgm TESTPGM, weird things start to happen with some
transaction's run under commit why they should not
of triggers compiled with commit=*none I can't understand why thisfdrzewiecki@xxxxxxxxxxxxxxxxx
one simple sql select break the whole setup.
Everything works just fine without embeded sql used in program.
DROP TABLE TESTLIB.TESTTABLE;
CREATE TABLE TESTLIB.TESTTABLE (
ID INTEGER GENERATED ALWAYS AS IDENTITY,
CODE INTEGER NOT NULL,
DESC CHAR(10) NOT NULL)
INSERT
INTO TESTLIB.TESTTABLE (CODE, DESC)
VALUES (1, ''), (2, '');
CREATE TABLE TESTLIB.TESTMQT ( TESTCODE, TESTDESC ) AS
(SELECT DECIMAL(CODE, 5), DESC
FROM TESTLIB.TESTTABLE) DATA INITIALLY IMMEDIATE
REFRESH DEFERRED ENABLE QUERY OPTIMIZATION MAINTAINED BY USER RCDFMT
TESTMQT ;
CREATE UNIQUE INDEX TESTLIB.TESTIDX
ON TESTLIB.TESTMQT (TESTCODE);
CREATE OR REPLACE TRIGGER TESTLIB.TESTTRGUP NO CASCADE BEFORE Update
On TESTLIB.TESTMQT REFERENCING OLD As vOld
NEW As vNew
For Each Row Mode DB2ROW
SET OPTION COMMIT=*NONE
BEGIN ATOMIC
UPDATE TESTLIB.TESTTABLE
SET
CODE = vNew.TESTCODE,
DESC = vNew.TESTDESC
WHERE
CODE = vOld.TESTCODE; END;
CREATE TABLE TESTLIB.TESTPF ( TESTCOL CHAR(10) NOT NULL) RCDFMT
TESTRF;
CREATE TABLE TESTLIB.TESTTBL(
ID INTEGER GENERATED ALWAYS AS IDENTITY,
COLUMN CHAR(10) NOT NULL)
CREATE OR REPLACE TRIGGER TESTLIB.TESTPFTRGUP NO CASCADE BEFORE
Update On TESTLIB.TESTPF REFERENCING OLD As vOld
NEW As vNew
For Each Row Mode DB2ROW
SET OPTION COMMIT=*NONE
BEGIN ATOMIC
UPDATE TESTLIB.TESTTBL
SET
COLUMN = vNew.TESTCOL
WHERE
COLUMN = vOld.TESTCOL; END;
INSERT INTO TESTLIB.TESTPF VALUES '';
TESTCL.CLLE
PGM
STRCMTCTL LCKLVL(*CHG) CMTSCOPE(*JOB) CALL TESTPGM COMMIT ENDCMTCTL
ENDPGM
TESTPGM.RPGLE
**FREE
Ctl-Opt DATEDIT(*DMY/) Option(*nodebugio:*srcstmt);
Dcl-F TESTPF Usage(*Update:*Delete:*Output) Commit; Dcl-F TESTIDX
Usage(*Update:*Delete:*Output) Keyed ; Dcl-S Index Packed(4) Inz(0);
dcl-s id int(5);
exec sql set option commit=*none;
exec sql select id into :id from testtable limit 1;
Dow Index < 100;
Setll(e) *start TESTPF;
Read(e) TESTPF;
TESTCOL = %Char(Index+1);
Update(e) TESTRF;
Chain(e) (2) TESTIDX;
TESTDESC = %Char(Index);
Update(e) TESTMQT;
Chain(e) (1) TESTIDX;
TESTDESC = %Char(Index);
Update(e) TESTMQT;
Setll(e) *start TESTPF;
Read(e) TESTPF;
TESTCOL = %Char(Index);
Update(e) TESTRF;
Index+=1;
EndDo;
*INLR = *on;
Filip Drzewiecki
RPG Developer
e-mail: fdrzewiecki@xxxxxxxxxxxxxxxxx<mailto:
----
This is the RPG programming on IBM i (RPG400-L) mailing list To post
a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.