When creating stored procedures and user-defined functions (UDFs), the SQL procedural language processor on the iSeries™ does not always generate the most efficient code. However, you can do some changes to reduce the number of database engine calls needed and improve performance.
Some changes are in the design of a routine and some are in the implementation. For example, differences between how the C language compiler handles host variables and the way the SQL procedural processor requires the host variables to be handled can cause many calls to the database engine. These calls are very expensive and, when done many times, can significantly degrade performance.