A new assessment utility makes it easy to keep stored procedures and functions synchronized!
As more IBM i applications utilize stored procedures and user-defined functions, processes must be put in place to manage these routines just like traditional IBM i program objects. You need to make sure the stored procedures and functions are moved from your development system to production system to ensure that that the application is able to run. Likewise, if you have a backup system that's used for disaster recovery, the routines also need to be propagated to the backup system.
Reference this Redbook for information on the methods to propagate DB2 stored procedures and user-defined from one system to another.
Even with good management processes in place, you need to verify that the routines have been properly propagated to the target system. Technology Refresh 6 (TR6) for the IBM i 7.1 release makes this verification easy with a new CHECK_SYSROUTINES assessment utility.
This new utility compares the stored procedures and user-defined functions in a specified schema (library) on two different systems and returns a list of the objects that do not exist on both systems. The utility is an IBM-provided stored procedure that resides in the SYSTOOLS schema that compares the contents of the QSYS2.SYSROUTINE catalog view on both systems for the specified schema. The following SQL CALL statement shows a sample invocation of the assessment stored procedure.
CALL SYSTOOLS.CHECK_SYSROUTINE ('BACKUPSYS', 'APPLIB', DEFAULT)
The first parameter is the name of the system that you want to assess against your current system. In this example, the utility is invoked on the production system (PRODSYS) and is assessing whether the same routines exist on the backup system (i.e., BACKUPSYS). The first input parameter is actually the name of a remote database, so whatever value is passed must match an entry in your current system's relational database directory. The Work with RDB Directory Entry (WRKRDBDIRE) command is the simplest way to review the entries in your directory. If an entry doesn't exist for the system that you would like to assess, use the Add RDB Directory Entry (ADDRDBDIRE) command to add the entry. The Distributed Database Programming Guide can be consulted for more details on remote databases.
The utility's second parameter is the schema that contains the stored procedures and user-defined functions that need to be assessed. In this example, the invoker has asked that the routines in the APPLIB schema be compared on the two systems. If you have stored procedures and user-defined functions that reside in multiple schemas, the CHECK_SYSROUTINES utility would need to be executed multiple times.
The third parameter dictates how the output of the assessment is returned. The default value is to return the assessment output as a stored procedure result set. Using this default output value means that you need to use an interface such as IBM i Navigator Run SQL Scripts, which has the ability to display a stored procedure result set. The utility output shown in Figure 1 was returned by IBM i Navigator's Run SQL Script interface. If the SQL interface being used doesn't support stored procedure result sets, then you can specify a value of 0. When a value of 0 is specified, the stored procedure returns no output; in this case, you'll have to manually query a temporary table named SYSRTNDIFF in the SESSION schema to access the assessment output.
As mentioned previously, Figure 1 contains the output returned by the CHECK_SYSROUTINE invocation. In this example, the production system had three stored procedures (PROC1, PROC2, PROC3) and a single user-defined function (FUNCTN1) in the APPLIB schema. From the output, you can see that the assessment utility found all of the routines on the back system except the PROC3 stored procedure. In this situation, you will need to review your routine management process to determine why the PROC3 procedure was not properly propagated to BACKUPSYS. If BACKUPSYS somehow had a routine that didn't exist on the production system, the result set would contain a row with a SERVER_NAME value of PRODSYS. If a routine is listed for both systems, this means that the routine has conflicting attributes (e.g., different number of parameters) on the two systems.
Figure 1: This shows partial output from CHECK_SYSROUTINES utility.
To access this new assessment utility, just load IBM i 7.1 Database Group PTF level 23 on your system. Once that's done, it will be much easier to verify that all of your stored procedures and user-defined functions are in synch across of all of your systems and partitions.
LATEST COMMENTS
MC Press Online