How to Use GET DIAGNOSTICS in SQLRPGLE to Retrieve Row Count on IBM i
How to Use GET DIAGNOSTICS in SQLRPGLE to Retrieve Row Count on IBM i In this post, I’ll walk you through a simple and effective way to retrieve the number of rows affected by SQL statements in your SQLRPGLE programs using the GET DIAGNOSTICS statement. Whether you're inserting, updating, or deleting rows, GET DIAGNOSTICS allows you to programmatically capture how many records were impacted. What You'll Learn How to use GET DIAGNOSTICS after an SQL operation How to check the number of rows inserted, updated, or deleted A practical example using two test tables Prerequisites Before running the example, create two tables using these SQL statements: CREATE TABLE TESTFILE ( TFTYPE CHAR(2) NOT NULL WITH DEFAULT, TFNUMB NUMERIC(7, 0) NOT NULL WITH DEFAULT ); CREATE TABLE TESTFILE2 ( TFTYPE CHAR(2) NOT NULL WITH DEFAULT, TFNUMB NUMERIC(7, 0) NOT NULL WITH DEFAULT ); Then populate TESTFILE with the following sample data: INSERT INTO T...