|TechTip: RUNSQLSTM Is Bigger and Better in V6R1|
|Tips & Techniques - Programming|
|Written by Kent Milligan|
|Thursday, 24 April 2008 19:00|
IBM continues to make life easier for SQL developers.
As SQL becomes more widely used by i5/OS developers, it's important for IBM to continue to enhance the tools and utilities supporting the SQL interface to increase the adoption of SQL. The Run SQL Statements (RUNSQLSTM) system command is one of those SQL utilities that is enhanced in V6R1 to make life easier for SQL developers.
RUNSQLSTM is widely used by developers for executing SQL scripts that create the database objects or SQL routines for their applications. In prior releases, this command was limited by the fact that it only supported source members that were 80 characters wide. Support for very large SQL scripts was also hampered by the fact that the source member had to be less than 16 MB in length. These limitations no longer exist as a result of the V6R1 enhancements.
The RUNSQLSTM now includes support for stream files. Stream files, by their nature, do not have a maximum line or record length. This means that developers creating SQL scripts in a stream file don't worry about running out of room on a line when typing in and formatting their SQL statements. In addition, the maximum size of a stream file is 1 TB, which is quite helpful when accommodating SQL scripts that are larger than 16 MB in size. Here's an example of the RUNSQLSTM command used to execute SQL statements stored in a stream file.
Those i5/OS developers who prefer to use source physical file members can also code wider SQL statements in V6R1. While it's not the unlimited record length that the stream file support offers, the RUNSQLSTM now supports a MARGINS parameter to allow developers to override the default length of 80 characters. The MARGINS parameter supports a maximum length of 32754. Here's an example of using this new parameter on the RUNSQLSTM command to accommodate wider SQL statements (120 characters per line in this example).
RUNSQLSTM SRCFILE(MYLIB/MYSRC) SRCMBR(TEST1) MARGINS(120)
The RUNSQLSTM command offers increased flexibility in V6R1 by adding support for CL commands. This new support mirrors the CL command support that's available with the System i Navigator Run SQL Scripts interface. The CL command in the SQL script needs to be prefixed with "CL:" and then a semi-colon after the CL command string. Here's an example of a script including CL and SQL statements that can be processed by RUNSQLSTM in V6R1.
CREATE TABLE tab1 (C1 INT, C2 CHAR(5)) ;
CL: CRTDTAARA DTAARA(DTA1) TYPE(*CHAR) LEN(5);
CREATE TABLE tab2 (col1 CHAR(1), col2 INT);
CREATE INDEX ix2 ON tab2(col2);
No special parameters are needed on the RUNSQLSTM command to enable the CL command support.
|Last Updated on Thursday, 17 April 2008 09:53|