V6R1 Run SQL Scripts: Saving Scripts to a System i Source File
June 17, 2009 Skip Marchesani
V6R1 brings some nice enhancements to Run SQL Scripts—which is part of the Database function in System i Navigator–that provide more function and make it easier to use. One of these V6R1 enhancements is the ability to save, and retrieve or open an SQL script to/from a System i source file, in addition to saving it to a PC or a stream file. The following example shows an SQL script called “custmstr3” that was originally saved as a PC file, and which will now be saved as a System i source file. The first step is to click on File on the left side of the toolbar, and then Save As in the resulting drop down menu as shown in Figure 1.
The resulting Save window provides the option to save the script as a PC file, stream file, or source physical file, with PC file as the default as shown in Figure 2.
Click on the down arrow on the right side of the “Save to” box at the top of the Save window and select Source Physical file, and the parameter data/information boxes required to save to a source file will appear as shown in Figure 3.
Provide the appropriate parameter data to do the save and then click Save on the right side of the Save window to save the SQL script to the designated System i source file. The Schema box is used to provide the name of the library where the SQL script will be stored, the Source file box provides the name of the source file, and the Member box provides the source member name for the SQL script. Use the default of “No margin” for “Right margin start”; the Source type should be SQL (for SQL scripts), and text can be optionally provided to document the SQL script as shown in Figure 4.
Note that each of the parameter boxes has a down arrow on the right side. Parameter data can be keyed into each of the boxes, or click on the down arrow to see the options available based on the schemas or libraries in library list for the Run SQL Scripts job. Once all the parameter data has been correctly entered, click on the Save button to initiate the save, which will take up to a couple of seconds depending on the speed of your network and activity on the System i. While the save is being done, the input pane of the Run SQL Scripts window will be grayed out. If a member of the same name already exists in the source file, a message will be displayed asking if you want to replace the existing file/member, as shown in Figure 5.
To open an SQL script stored as a System i source file, click on File in the toolbar, and then Open in the resulting drop down widow. The Open widow will be displayed with the default Open parameter of PC file. Change the Open parameter to Source physical file, fill in the required parameters, and click Open as shown in Figure 6.
Skip Marchesani retired from IBM after 30 years and is now a consultant with Custom Systems Corporation. He is also a founding partner of System i Developer and the RPG & DB2 Summit. Skip spent much of his IBM career working with the Rochester Development Lab on projects for S/38 and AS/400 and was involved with the development of the AS/400. He was part of the team that taught early AS/400 education to customers and IBM lab sites worldwide. Skip is recognized as an industry expert on DB2 for i and the author of the book DB2/400: The New AS/400 Database. He specializes in providing customized education for any area of the System i, iSeries, and AS/400; does database design and design reviews; and performs general System i, iSeries, and AS/400 consulting for interested clients. He has been a speaker for user groups, technical conferences, and System i, iSeries, and AS/400 audiences around the world. He is an award-winning COMMON speaker and has received its Distinguished Service Award. Send your questions or comments for Skip to Ted Holt via the IT Jungle Contact page.
|