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

Since you asked on the RPG list, here is a quick and simple example how you
could use the ROW CHANGE TOKEN in RPG.

Hope that helps you to find a use for it.

Regards,
-Arco

//------------------------------------------------------------------//
// CREATE TABLE MyRcTest
// ( MyID INTEGER, MyDesc CHAR(20)
// ) ;
// INSERT INTO MyRcTest (MyID, MyDesc) VALUES (1, N'Desc abc') ;
//
// Build instruction:
//
// *> ign: DLTPGM PGM(&O/&ON)
// *> CRTSQLRPGI OBJ(&O/&N) -
// *> SRCFILE(&L/&F) -
// *> COMMIT(*NONE) -
// *> OBJTYPE(*PGM) -
// *> DBGVIEW(&DV)
// Variables
d beforeRct S 20I 0
d afterRct S 20I 0
d wwDesc S 20A
//------------------------------------------------------------------//
// Main program
//------------------------------------------------------------------//
/free
*inlr = *on ;
EXEC SQL
SELECT
ROW CHANGE TOKEN FOR aa,
aa.MyDesc INTO :beforeRct, :wwDesc
FROM MyRcTest AS aa
WHERE aa.MyID = 1 ;
IF NOT (%subst(sqlstt:1:2)='00' OR %subst(sqlstt:1:2)='01') ;
DSPLY ('SQL Error, state is ' + sqlstt) ;
return ;
endif ;
// send the wwDesc and the beforeRct to you displayfile or
browserpage
// and wait there for user input.
DSPLY (%trim(wwDesc) + '/' + %char(beforeRct)) ;
// in the meantime try to update the record from another process:
//
// UPDATE MyRcTest SET MYDESC = N'Desc xyz' WHERE MYID = 1 ;
// When the values are returned from the front, then check whether
the
// filerecord is still the same. It might have been changed in
another
// parallel process.
EXEC SQL
SELECT
ROW CHANGE TOKEN FOR aa INTO :afterRct
FROM MyRcTest AS aa
WHERE aa.MyID = 1 ;
if not (%subst(sqlstt:1:2)='00' or %subst(sqlstt:1:2)='01') ;
DSPLY ('SQL Error, state is ' + sqlstt) ;
return ;
endif ;
if beforeRct = afterRct ;
// ok, that is fine, you can update the file
DSPLY ('Before and after token are equal' ) ;
else ;
DSPLY ('RC B/A : '
+ %char(beforeRct) + '/' + %char(afterRct)) ;
endif ;
return ;
/end-free

2017-12-27 22:56 GMT+01:00 Booth Martin <booth@xxxxxxxxxxxx>:

Rudimentary questions follow. I believe I read the material correctly. I
also believe I have misunderstood what I read. Hence the questions.

This venture in to ROW CHANGE TOKEN territory is because of
recommendations made here. The whole concept is brand new ground for me.
I am looking to solve the "was it changed at another workstation?" problem.

Is ROW CHANGE TOKEN a reliable solution or do I need to also use a
timestamp column and compare both fields?

Is ROW CHANGE TOKEN a valid solution for V5R4 releases & forward?

This statement gives me SQL 0104:

CHANGE_TS TIMESTAMP FOR EACH ROW ON UPDATE
AS ROW CHANGE TIMESTAMP NOT NULL);

This is a direct copy/paste from an IBM site.

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
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: http://amzn.to/2dEadiD

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.