IBM i5/iSeries Primer(c) Concepts and Techniques for Programmers, Administrators, and Sys[... ]ators
IBM now includes the RUNSQLSTM command, shown in Figure 25.40, within the base operating system for i5 and iSeries. In earlier releases of the operating system, this command was provided through a licensed program product. Similar to the GUI Run SQL Scripts application discussed earlier in this chapter, this command executes the SQL statement stored in a source file on the i5 server. Use the editor of your choice to enter the statements.
If you are not using commitment control, be sure to change the commitment control parameter to *NONE when performing any database updates. Otherwise, the SQL updates will fail. The Naming parameter of *SYS indicates that file and library names are separated by a ‘/’ *SQL changes the separator to a period (‘.’).
The Source file and member reference a prewritten SQL statement, such as that shown in Figure 25.41.
The code in the MYSQLCMD source member actually includes two separate SQL statements. Just as with the Run SQL Script wizard, multiple SQL statements may be entered with a semi-colon (‘;’) ending each statement. The RUNSQLSTM command will execute every statement in the source file. If an error occurs, the command will abort and issue the message RUNSQLSTM command failed.
If this message is sent, see the job log for more information on the specific cause of the failure. The RUNSQLSTM command is a useful tool when you have a series of static SQL statements to execute. With no convenient method for passing parameters to the statement, its usefulness remains somewhat limited.