TechTip: RUNSQLSTM Is Bigger and Better in V6R1

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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. 

 

   RUNSQLSTM SRCSTMF('/home/tests/script1.txt')

 

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.

Kent Milligan
Kent Milligan is a Senior Db2 for i Consultant in the IBM Lab Services Power Systems Delivery Practice.  Kent has over 25 years of experience as a Db2 for IBM i consultant and developer working out of the IBM Rochester lab. Prior to re-joining the DB2 for i Lab Services practice in 2020, Kent spent 5 years working on healthcare solutions powered by IBM Watson technologies. Kent is a sought-after speaker and author on Db2 for i & SQL topics.
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: