arg db user password nrows
/* Connect the target database. Exit if connect
fails. */
"REXXSQL CONNECT" user "IDENTIFIED BY" password "TO" db
if sqlcode < 0 then exit 8
/* Prepare and execute a SELECT on SYSCATALOG. */
s = "SELECT CREATOR,TNAME,ROWCOUNT FROM SYSTEM.SYSCATALOG"
,
"WHERE ROWCOUNT >=" nrows "ORDER
BY ROWCOUNT DESC"
"REXXSQL OPEN" s
/* Check for SQL errors. */
if SQLCODE <> 0 then signal SQL_error
/* Show the result stems CREATOR, TNAME and ROWCOUNT */
"REXXSQL FETCH"
do while sqlcode = 0
tablename = strip(creator)"."strip(tname)
say "Table" tablename "has" rowcount "rows"
"REXXSQL FETCH"
end
if SQLCODE < 0 then signal SQL_error
/* Terminate */
"REXXSQL CLOSE"
"REXXSQL COMMIT"
exit
/* Show SQLCODE, SQLERRM and related help text */
SQL_error:
call REXXSQLH sqlcode sqlerrm
exit 8