|
I'm looking for the number of records that will be deleted based on selection criteria before I actually copy and delete them.
-----Original Message-----
From: RPG400-L<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Vern Hamberg via RPG400-L
Sent: Tuesday, February 17, 2026 9:04 AM
To:rpg400-l@xxxxxxxxxxxxxxxxxx
Cc: Vern Hamberg<vhamberg@xxxxxxxxxxxxxxx>
Subject: Re: External RE: Count records in SQL
Hi Jerry
I'm coming in at the end of this thread, perhaps. So am asking, did anyone suggest using SQLTABLESTAT to get row counts? There is also the OBJECT_LOCK_INFO SQL service that could be joined to SYSTABLESTAT.
Just curious, but these would let you get what you want without running SELECTs over each table, which my memory says you are thinking to use.
Nice project!
*Regards*
*Vern Hamberg*
IBM Champion 2025<cid:part1.xmvjuurl.t0cb6Uqj@centurylink.net> CAAC (COMMON Americas Advisory Council) IBM Influencer 2023
On 2/17/2026 7:56 AM, Jerry Forss wrote:
Thank you ALL for your great explanations!--
What I am doing is setting up a purge process for our main packages
This has NEVER been done as they always wanted to have all history for ever and ever.
This has caused several issues, not to say the least Invoice Numbers being reused some 15 years later.
1 - Get Purge through date (I have convinced them at 8 years)
2 - List all files to be purged and use SQL to determine number of records that are going to be purged using SQL.
This will also verify that there are no locks on the file as well.
3 - Display list file files/records as a verification.
4 - If No locks found and continue is selected.
Create Purge Library
Loop until done
Allocate file
CrtDupObj of each File in Purge Library
CPYF records from Live File to Duplicate file
Delete records from Live File using SQL
Reorg file
UnAllocate file
We have plenty of space on our box so no need to remove them from the system and want them somewhere incase
They MIGHT be needed in an inquiry.
Again, thank you all!
-----Original Message-----
From: RPG400-L<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Birgitta Hauser
Sent: Thursday, February 12, 2026 10:51 PM
To: 'RPG programming on IBM i'<rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: External RE: Count records in SQL
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
GET DIAGNOSTICS ... will only return information AFTER an SQL Statement is run.
ROW_COUNT: (Except from the SQL Reference) Identifies the number of rows associated with the previous SQL statement that was executed. If the previous SQL statement is a DELETE, INSERT, REFRESH, or UPDATE statement, ROW_COUNT identifies the number of rows deleted, inserted, or updated by that statement, excluding rows affected by either triggers or referential integrity constraints. If the previous SQL statement is a MERGE statement, ROW_COUNT identifies the total number of rows deleted, inserted, and updated by that statement, excluding rows affected by either triggers or referential integrity constraints. If the previous SQL statement is a multiple-row-fetch, ROW_COUNT identifies the number of rows fetched.
Otherwise, the value zero is returned.
May be DB2_NUMBER_ROWS would be the better option: (Except from the SQL
Reference)
If the previous SQL statement was an OPEN or a FETCH which caused the size of the result table to be known, returns the number of rows in the result table. For SENSITIVE cursors, this value can be thought of as an approximation since rows inserted and deleted will affect the next retrieval of this value. Otherwise, the value zero is returned.
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
Modernization - Education - Consulting on IBM i Database and Software Architect IBM Champion since 2020
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok) "What is worse than training your staff and losing them? Not training them and keeping them!"
"Train people well enough so they can leave, treat them well enough so they don't want to. " (Richard Branson) "Learning is experience .. everything else is only information!" (Albert
Einstein)
-----Original Message-----
From: RPG400-L<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jimmy Sansi
Sent: Thursday, 12 February 2026 21:44
To: RPG programming on IBM i<rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Count records in SQL
What about ...
exec sql GET DIAGNOSTICS :Rows = ROW_COUNT;
https://www.ibm.com/docs/en/i/7.5.0?topic=statements-get-diagnostics
On 2026-02-12 12:15, Jerry Forss wrote:
I have a SQL--
SqlSelect = 'SELECT C6DcCd, ' +
'C6CvNb, '+
'C6AcDt, ' +
'C6FnSt,' +
'C6B9Cd ' +
'From ' + %Trim(PurgeXALib) + '/MBC6REP ' + 'Where C6ACDT <= ' +
%EditC(PurgeDateCYMD : 'X');
Instead of reading through the cursor, I want the number of records
found.
How do I do that?
This is the RPG programming on IBM i (RPG400-L) mailing list To post a messageemail:RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:https://lists.midrange.com/mailman/listinfo/rpg400-l
oremail:RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives athttps://archive.midrange.com/rpg400-l.
Pleasecontactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a messageemail:RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:https://lists.midrange.com/mailman/listinfo/rpg400-l
oremail:RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives athttps://archive.midrange.com/rpg400-l.
Pleasecontactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email:RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:https://lists.midrange.com/mailman/listinfo/rpg400-l
or email:RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
athttps://archive.midrange.com/rpg400-l.
Please contactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.
Subject to Change Notice:
WalzCraft reserves the right to improve designs, and to change specifications without notice.
Confidentiality Notice:
This message and any attachments may contain confidential and privileged information that is protected by law. The information contained herein is transmitted for the sole use of the intended recipient(s) and should "only" pertain to "WalzCraft" company matters. If you are not the intended recipient or designated agent of the recipient of such information, you are hereby notified that any use, dissemination, copying or retention of this email or the information contained herein is strictly prohibited and may subject you to penalties under federal and/or state law. If you received this email in error, please notify the sender immediately and permanently delete this email. Thank You
WalzCraft PO Box 1748 La Crosse, WI, 54602-1748
www.walzcraft.com<https://www.walzcraft.com> Phone: 1-800-237-1326
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.