When you use the SQL_RunSQLSel function, it is useful to know whether the SELECT statement resulted in an empty recordset. You can test for this condition using the SQL_LastFullErr function.

The following example assumes that you have already connected to RPG2SQL PC Component, you have received a socket in variable SQL_Socket, and you have an indicator variable hasRecords. Use the following code to run the SELECT statement and check whether there are any rows in the recordset:

/free
Rtn = SQL_RunSQLSel(SQL_Socket : 'select * from NameAddr where first = ''James''');

// ADO/SQL database operation "failed"
If Rtn = -1;

// If no error is reported, then the recordset is empty
If SQL_LastFullErr(SQL_Socket) = '0';
hasRecords = *off;
EndIf;

EndIf;
/end-free

 


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: December 10, 2016