Originally posted by Barbara Morris
View Post
Announcement
Collapse
No announcement yet.
OAR and joined LF's
Collapse
X
-
my latest struggle...
as an attempt to get familiar with the OAR behavior, I have my rpg pgm doing this...
chain ('01'
:'1001-80641-1 '
:'012'
:0000000
:'PI') srvbmst;
if %found(srvbmst);
dsply (%trim(zbmst2));
endif;
read srvbmst;
if not %eof(srvbmst);
dsply (%trim(zbmst2));
endif;
readp srvbmst;
if not %eof(srvbmst);
dsply (%trim(zbmst2));
endif;
*inlr = *on;
the chain works fine... i then want to do the read and finally the readp... the read is getting a pointer error
Pointer not set for location referenced.
attached is the handler pgm code
figured i'll be stuck on this one for a while so thought i'd go ahead and signal for help...
You'll see where I'm trying to keep it as simple as possible and reuse the handleChain() procedure for CHAIN/READ/READP... by simply renaming it handleGetRecord() and passing it either "FIRST", "NEXT", or "PRIOR", as these relate to sql cursor fetch operations. If I can maintain this design, i'd really like to do so.
Attached Files
Comment
-
so here's the recent issue...
RLA
chain (some key) fileA
record found
readp... reads record prior to chained record no problem...
SQL
my chain equivalent looks like...
g_sqlStmt = 'select * ' +
'from ' + %trim(l_table) + ' ' +
'where bankno >= ? ' +
'and bankac >= ? ' +
'and inv# >= ? ' +
'and pool# >= ? ' +
'and type >= ? ' +
'for fetch only';
exec sql
prepare s1 from :g_sqlStmt;
exec sql
declare c1 scroll cursor for s1;
exec sql
open c1 using :i_bankno
,:i_bankac
,:i_inv#
,:i_pool#
,:i_type;
exec sql
fetch first from c1 into _dsInpRcd
_indArray;
I'll admit, my chain equivalents in regular embedded rpg is usually a select into, but Dan encouraged using the cursor to leverage other opcodes such as read/readp
however based on how my select statement was built, i hit an EOF on a READP prior to my key value because of the >=
i do the readp by simply... utilizing the current cursor and...
exec sql
fetch prior from c1 into _dsInpRcd
_indArray;
so what is the best modification to allow a chain and then a readp (to access records, prior to the chain in the selected record set)?
Comment
Comment