Simple SQLRPGLE Program
**Free
Ctl-Opt
// nomain
dftname(XXXXXX)
debug(*YES)
datfmt(*iso)
timfmt(*iso)
ExtBinInt(*yes)
Option( *SrcStmt : *NoDebugIO : *NoUnRef)
CCSID(*Char:*JobRun)
;
Dcl-S lc_field Char(10);
Dcl-S lc_SEQ Packed(5);
Dcl-S lc_screen_mode Char(1);
Dcl-S lc_Screen Char(10);
Dcl-S lc_max_seq Packed(5);
//Set SQL options
Exec sql
SET OPTION commit=*none, closqlcsr=*EndMod ;
Exec sql
Declare es_cursor scroll Cursor For
Select XXV8GQ, SEL0002, XXV4UA, XXWAGQ
From SUDESV2 order by XXV8GQ;
Exec sql
Open es_cursor;
Exec sql
Fetch Next From es_cursor into :lc_field, :lc_SEQ,
:lc_screen_mode, :lc_Screen;
Dow SQLCODE = 0;
Exec sql
Select max(SEL0002) Into : lc_max_seq
From SUDESV2
Where XXV8GQ= :lc_field;
If lc_max_seq > 0;
lc_max_seq = lc_max_seq + 1;
Exec sql
Update SUDESV2 set SEL0002= :lc_max_seq where
XXV8GQ=: lc_field and SEL0002 =:lc_SEQ
and XXWAGQ =:lc_Screen and XXV4UA=:lc_screen_mode;
EndIF;
Exec sql
Fetch Next From es_cursor into :lc_field, :lc_SEQ,
:lc_screen_mode, :lc_Screen;
EndDo;
Exec sql
Close es_cursor;
*INLR = *ON;