RPGFree reading and updating a file using SQL embedded syntax
Reading and Updating a File Using SQL Embedded in RPGFree In this tutorial, I’ll show you how to read a file from the beginning and update a field in the same file using embedded SQL in free-format RPG IV (RPGFree). Step 1: Create the Physical File First, we need to create a file and populate it with some test data. Create the file using the following SQL source: Source member: IPFLSQL Source file: myLib/MySourceFile -- IPFLSQL.SQL -- Create the physical table IPFLI00F CREATE OR REPLACE TABLE myLib/IPFLI00F ( IIFANN CHARACTER(1) NOT NULL WITH DEFAULT, IITEXT CHARACTER(25) NOT NULL WITH DEFAULT ) RCDFMT IPFLI; Run this member with the following command: RUNSQLSTM SRCFILE(myLib/MySourceFile) SRCMBR(IPFLSQL) Now, manually insert a few records into the file IPFLI00F using DFU, ACS, or any method of your choice. The values are not important — just a few test records. Step 2: Compile and Run the RPG Program Below is the RPGFree program that reads all records ...