× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi again,

To anyone interested. IBM has confirmed this is a bug and they gave us PTF which solves this problem.
It should be official in March(probably).

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Filip Drzewiecki via RPG400-L
Sent: Friday, February 14, 2020 4:22 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Cc: Filip Drzewiecki <fdrzewiecki@xxxxxxxxxxxxxxxxx>
Subject: RE: Transaction runs under commit while it should not

"SET OPTION isn't enough, it merely sets a default. An SQL trigger does a SET TRANSACTION to match it's caller's commit mode."
Well program is compiled with commit=*none so I don't see a reason why transaction runs under commit here.
Even if commit is started on job and this is set isolation level to anything other than *none, program is compiled with commit *none

Adding SET TRANSACTION ISOLATION LEVEL NO COMMIT in trigger solve the problem as described earlier but we get same result adding line with exec sql values 1 into :id; and this makes no sense to me. Why this one statement somehow change isolation level to NONE?

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Charles Wilt
Sent: Friday, February 14, 2020 3:21 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Transaction runs under commit while it should not

Read the redbook I posted a link to...

SET OPTION isn't enough, it merely sets a default. An SQL trigger does a SET TRANSACTION to match it's caller's commit mode.

You could include your own SET TRANSACTION ISOLATION LEVEL NO COMMIT

If you never want the trigger to be run under the caller's commit...

But using ATOMIC will have the trigger's work done in it's own cycle.


On Fri, Feb 14, 2020 at 1:51 AM Filip Drzewiecki via RPG400-L < rpg400-l@xxxxxxxxxxxxxxxxxx> wrote:

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,

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
in
another loop it run under commit again(in TESTPGM I do updates in
loop
and
it looks every run it behave differently).
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
because
of triggers compiled with commit=*none I can't understand why this
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:
fdrzewiecki@xxxxxxxxxxxxxxxxx

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

--
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 thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.