Figure 3: Embedded SQL in free-format RPG (V5R4)
/Free Exec Sql Declare C1 Cursor For Select Address, State, Zipcode From Mmaster For Update Of Delpoint, Carroute; Exec Sql Open C1; Dou Sqlcod <> 0; Exec Sql Fetch C1 Into :Address, :State, :Zipcode; Exsr Srdelp; Exsr Srcarr; Exec Sql Update Mmaster Set Delpoint = :Delpoint, Carroute = :Carroute Where Current Of C1; Enddo; Exec Sql Close C1; *Inlr = *On; Return; /End-free