• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Saving and Restoring External SQL Routine Definitions

    January 30, 2008 Hey, Mike

    A vendor whose software we use separates objects into two main libraries–a data library and an object library. I had to restore all the data, so I deleted the data library and restored it. After that, the application stopped working. The problem turned out to be that some stored procedures that they created in their data library got wiped out, and the Restore Library (RSTLIB) command didn’t put them back. The story ends happily because the vendor had a program in place for just such emergencies, but (and I’m sure IBM disagrees), I consider this a big old bug in the SAVE/RESTORE command. If I restore a library, I want everything in the library restored.

    –Joe

    Well this is indeed a thorny problem. First let’s review what’s happening here:

    • The software has logic existing in program and/or service programs, presumably written in some high-level language such as RPG, C, or COBOL.
    • To make these programs available to the SQL world, the vendor executed the external version of the CREATE PROCEDURE SQL statement, which allows SQL to run these programs.
    • These external SQL routine definitions, whether they be stored procedures or user-defined functions, are stored in the SQL system catalogs in library QSYS2. Essentially these definitions are merely “pointers” telling DB2 for i5/OS how it can make use of high-level language (HLL) programs.

    And now a problem arises. Since these definitions are more or less pointers, not i5/OS objects themselves, how should IBM handle saving and restoring them? The answer IBM came up with is to associate the external SQL routine definition with the corresponding HLL program or service program object. When the program object is backed up, the SQL routine definition is captured as well. Subsequently when the program object is restored, the SQL routine definition is restored. Therefore, restoring the library will not restore the SQL routine definition unless the program object is in that library.

    In this case, the vendor chose to assign the SQL routine definitions’ schema with the data library rather than the program library. Hence when the data library was deleted, all of the SQL routine definitions were deleted. When the data library was restored, only the data objects were put back on the system. Since the program objects were never restored, the SQL routine definitions were never re-created. As mentioned, IBM chose to associate the routine definition at the program and service program level rather than at the library level. I agree with this because you can control what is being restored at the object level–if you only restore one program then only that program’s definition are restored. You wouldn’t want to have to restore an entire library to restore the SQL routine definition for one program. Unfortunately, this creates a problem in this situation where the user wanted the routine definitions restored with the library.

    To avoid this problem, generally I like to create the external SQL routine definitions in the same schema (i.e., library) as the HLL program objects. I don’t know why the vendor opted to use this cross library approach. Perhaps there is a good reason, such as the application builds SQL statements that use the SQL naming convention and use qualified schema names–I’m only guessing.

    Incidentally, there is one other thing to note when allowing for the saving and restoring of external SQL routine definitions. Because the definition is saved with the program object, the program object should exist when the external CREATE statement is issued because this is when the program object is supplied the extra SQL information needed to backup the routine definition. If the program does not exist when the CREATE statement is issued, the routine will still exist but you’ll receive the following warning: SQL7909–Routine XYZ was created, but cannot be saved and restored.

    This message simply signals that the SQL routine definition has been created but since no program object exists yet there is no way to associate the definition with the program for the save operation.

    This also has implications for re-compilation of programs and service programs. A service program may have several associated SQL routines defined. Say a service program has 10 external routines defined against it. You fix a bug in the service program and then re-compile it. What then? The routine definitions are no longer associated with the service program object and hence will not be backed up.

    The lesson here is that whenever you re-create a program that has one or more external SQL routines defined, you should drop and re-create the associated routine definitions so they continue to be associated with the program object and backed up as expected. To do this effectively, you may need to run SQL scripts for each of your program objects (similar to what this vendor did) so that this process is painless as possible.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    New Generation Software

    FREE Webinar:

    Creating Great Data for Enterprise AI

    Enterprise AI relies on many data sources and types, but every AI project needs a data quality, governance, and security plan.

    Wherever and however you want to analyze your data, adopting modern ETL and BI software like NGS-IQ is a great way to support your effort.

    Webinar: June 26, 2025

    RSVP today.

    www.ngsi.com – 800-824-1220

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    COMMON:  Join us at the annual 2008 conference, March 30 - April 3, in Nashville, Tennessee
    BCD:  WebSmart offers you more Web Application Development choices
    Vision Solutions:  Enter to win an iPod Touch. Just download any of our DR planning resources

    IT Jungle Store Top Book Picks

    Getting Started with PHP for i5/OS: List Price, $59.95
    The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
    The System i Pocket RPG & RPG IV Guide: List Price, $69.95
    The iSeries Pocket Database Guide: List Price, $59.00
    The iSeries Pocket Developers' Guide: List Price, $59.00
    The iSeries Pocket SQL Guide: List Price, $59.00
    The iSeries Pocket Query Guide: List Price, $49.00
    The iSeries Pocket WebFacing Primer: List Price, $39.00
    Migrating to WebSphere Express for iSeries: List Price, $49.00
    iSeries Express Web Implementer's Guide: List Price, $59.00
    Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
    Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
    Getting Started with WebSphere Express for iSeries: List Price, $49.00
    WebFacing Application Design and Development Guide: List Price, $55.00
    Can the AS/400 Survive IBM?: List Price, $49.00
    The All-Everything Machine: List Price, $29.95
    Chip Wars: List Price, $29.95

    FalconStor Debuts New VTL Release Entry System p Servers Get Power6 Chips, System i Boxes Await

    Leave a Reply Cancel reply

Volume 8, Number 4 -- January 30, 2008
THIS ISSUE SPONSORED BY:

ProData Computer Services
Guild Companies
WorksRight Software

Table of Contents

  • Saving and Restoring External SQL Routine Definitions
  • Create Multiple Directory Levels in One Swell Foop
  • User Storage Limits and Application Processing

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle