06 Using CURSOR and FETCH into host var

**FREE

Dcl-ds InRec extname(FILEA) end-ds;

dcl-s FIELDA2 like(FIELDA);
dcl-s FIELDB2 like(FIELDB);

exec sql declare c1 cursor for select FIELDA, FIELDB from FILEA;
exec sql open c1;
exec sql fetch c1 into :FIELDA2, :FIELDB2;

dou sqlstt <> '00000';
    //  Do something with each record
    exec sql fetch c1 into :FIELDA2, :FIELDB2;
enddo;

exec sql close c1;
*inlr = *on;   

Comments

Popular posts from this blog

07 Using CURSOR and FETCH into host DS

12 FETCH and sub-procedures