They say a picture is worth a thousand words. I say that, sometimes, a single DELETE SQL statement is worth a thousand lines of RPG code. Let me show you how…and why.
By Rafael Victória-Pereira
You’ve been reading on and on about embedded SQL for quite a few articles now (sorry about that) without a word about INSERT, UPDATE, or DELETE. Don’t think for a minute that you can only embed SELECT statements in your RPG! You can issue INSERT, UPDATE, and DELETE commands from your code as easily as you use SELECT. However, RPG and SQL don’t play nice when it comes to changing data in the same file within the same program. If you want to update a bunch of records in a file that you’re also using in the program, the file must be closed before you issue the UPDATE statement.