When working with embedded SQL in an RPG, you often get a cursor and dow-loop to process all the lines in your result. Does the condition in the loop somehow depend on SQLCODand / or SQLSTTsome globally available variables in SQLRPGLE?
But what is the correct way to check these values? Some offer SQLCOD = 0others not (SQLCOD = +100 or SQLSTT = '02000'). One of them does not work with all warnings, the other does not lead to some errors, so I am not satisfied.
To illustrate what I'm doing with some code:
Pmain B
D PI
Dmy_ds E DS extname(SOME_TABLE)
D qualified
/free
exec sql
DECLARE cur CURSOR FOR
SELECT *
FROM some_table;
exec sql
OPEN cur;
exec sql
FETCH cur
INTO :my_ds;
dow sql_found();
exec sql
FETCH cur
INTO :my_ds;
enddo;
exec sql
CLOSE cur;
/end-free
Pmain E
Psql_found B
D PI N
/free
// insert return statement here...
/end-free
Psql_found E
, , , , . .