Rookie Question

Scott Klement's open source interface to using JDBC database drivers from RPG. http://www.scottklement.com/jdbc/
Post Reply
Angel.Bermudez
Posts: 3
Joined: Wed Dec 11, 2024 10:16 pm

Rookie Question

Post by Angel.Bermudez »

I was looking for examples on how to execute stored procedures and i found the code below. Can anyone tell me why
JDBC_getMoreResults() is called after the do while IsResultSet(), would not the JDBC_getResultSet() call get every
item in the record set?

Thanks for any answer.


/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
dcl-sstmt like(CallableStatement);
dcl-srs like(ResultSet);
dcl-sIsResultSet ind;

... Connect as before, etc....

stmt = JDBC_PrepCall( conn : 'call order_new(012001)' );

IsResultSet = JDBC_execCall( stmt );

dow IsResultSet;
rs = JDBC_getResultSet( stmt );

dowJDBC_nextRow(rs);
field1 = JDBC_getCol(rs: 1);
field2 = JDBC_getColByName(rs: 'SHIPNAME');
... do something with the data...
enddo;

IsResultSet = JDBC_getMoreResults( stmt );

enddo;

JDBC_FreeCallStmt(stmt);
JDBC_Close(conn);
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: Rookie Question

Post by Scott Klement »

Angel.Bermudez wrote: Thu Dec 12, 2024 4:15 pm I was looking for examples on how to execute stored procedures and i found the code below. Can anyone tell me why
JDBC_getMoreResults() is called after the do while IsResultSet(), would not the JDBC_getResultSet() call get every
item in the record set?
Stored procedures can have multiple result sets. This code iterates through all of the result sets. JDBC_getResultSet() only gets one of them. JDBC_getMoreREsults() advances to the next result set so you can get that.
Post Reply