Use these tips for running and calling iSeries™ stored procedures.
ODBC provides a standard interface for calling stored procedures. The implementation of stored procedures differs significantly across various databases. This simple example follows the recommended approach for running a stored procedure on the iSeries server:
Use care in coding the SQLBindParameter functions. Never use Visual Basic strings as a buffer when binding either columns (SQLBindCol) or parameters (SQLBindParameter). Instead, use byte arrays, which–unlike strings–will not be moved around in memory. See Example: Call an iSeries stored procedure by using Visual Basic for more information.
Pay careful attention to the data types that are involved. There may be subtle differences with those that you use with, for instance, a select statement. Also, ensure that you have an adequately sized buffer for output and input/output parameters. The way that you code the stored procedure on the iSeries server can affect performance significantly. Whenever possible, avoid closing the program with exit() in C language and with SETON LR in RPG language. Preferably, use RETRN or return, but you may need to re-initialize variables on each call, and by-pass file opens.