SQL PL–The FOR Loop
November 1, 2016 Ted Holt
SQL PL has four looping structures. The most useful one, to my way of thinking, is the FOR structure. It is different from–and more powerful than–the RPG FOR op code, and it’s easy to learn and use. Here’s how it works. FOR iterates over a read-only result set and terminates when there are no more rows to process. Think of a FOR loop as a read-only cursor without the messiness of OPEN, FETCH, and CLOSE. Let me illustrate with a stored procedure. create or replace Procedure Billing (in p_BillingCycle dec(3)) for One_Customer as select c.AccountNumber from customers as c where |