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

Sorry for not including compilation parameters. Totally forgot about it ☹
CRTSQLRPGI bsobjkg/TESTPGM SRCSTMF('/home/lib/bsobjkg/Src/QRPGLESRC/TESTPGM.SQLRPGLE') COMMIT(*NONE) DBGVIEW(*SOURCE) TEXT('Test program for IBM')

1. It runs in QILE for this test
2. Commit is set to *NONE (as it can be seen above in the email)
3. Well basically because of program is compiled with commit =*None it should works as we expect but it does not ☹
From what I understand is that because program is compiled with COMMIT(*NONE), those embedded SQL statement also run without commit.
What is even more funny, adding some dummy sql after update, fix the whole situation .... We are totally lost.

**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 select id into :id from testtable limit 1; //this simple select break isolation level somehow?
Dow Index < 100;
    Setll(e) *start TESTPF;
    Read(e) TESTPF;
    TESTCOL = %Char(Index+1);
    Update(e) TESTRF;
    exec sql values 1 into :id; // adding this line has fixed the issue and now updates run without commit as they should...
    Chain(e) (2) TESTIDX; 
    TESTDESC = %Char(Index);
    Update(e) TESTMQT;

    Index+=1;
EndDo;

*INLR = *on;


I've started ticket with IBM but I'm afraid it will take long time and well, time is luxury and we can’t afford that 😊

"What happens if you add WITH NC to the end of all SQL statements that should not run under commit?"
How this apply if program is compiled with commit=*none?
" What happens if you add WITH NC to the end of all SQL statements that should not run under commit?"
Program is compiled with commit=*none



-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Birgitta Hauser
Sent: Friday, February 14, 2020 10:52 AM
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Transaction runs under commit while it should not

Hmmm ... a few thoughts!
1. When testing, could it be your program runs in different activation groups (because of activation group *CALLER)?
2. When compiling your embedded SQL program, how is the COMIT set? (to *NONE or the default)?
3. Is commitment control always started when you run your program or your trigger gets fired?
If commitment control is not started, (embedded) SQL may start it by itself with Default Values (and Default Commitment Scope is *ACTGRP and not *JOB).
The trigger program should not start commitment control because it includes COMMIT = *NONE, but your RPG program includes an SQL Statement and might be compiled with COMMIT = *CHG
... and in this way SQL may start commitment control.
When removing the EXEC SQL, i.e. not running SQL statements in your program, the SQL runtime will not start commitment control. This might be the reason, why it runs correctly when removing exec SQL.

What happens if commitment control is started as soon the job gets started and not ended before the job end?
What happens if you add WITH NC to the end of all SQL statements that should not run under commit?

On the other hand, why not open a PMR at IBM ... what happens sound a little strange

Mit freundlichen Grüßen / Best regards

Birgitta Hauser


"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok) "What is worse than training your staff and losing them? Not training them and keeping them!"
„Train people well enough so they can leave, treat them well enough so they don't want to.“ (Richard Branson)


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

Also it means that ALL OPERATIONS must succeed but it does not mean that they all run under commit if trigger has ATOMIC keyword. They can be rolled back from Journal if commit cycle is 0 and you do not need commit for that.

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

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

Replies:

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.