Home > AS/400 Tips > iSeries administrator tips > Stored procedures: Balance network loads -- part 1
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

Stored procedures: Balance network loads -- part 1


Ron Turull
01.17.2007
Rating: -4.12- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



Ron Turull

SQL (Structured Query Language) stored procedures are a great feature. They provide an excellent tool to help optimize client/server applications. By shifting key portions of the processing onto the server, network data flows can be reduced substantially. All this without bogging down the server, which is the reason you went to client/server in the first place.

More Information

What is a stored procedure

Stored procedures are actually a concept -- a specification to allow a client application (called the Application Requester or AR) to run a series of instructions stored on the server machine (the Application Server or AS) instead of transmitting the instructions one by one. Thus, the implementation of stored procedures on the iSeries is two-fold:

  • The procedure containing the instructions can be any iSeries program.

  • Procedures are called from the client (not necessarily a PC) using the SQL CALL statement.

    Because SQL is used to implement stored procedures, the reader should have a basic understanding of it. If the server is an iSeries, it is not required to have the DB2 Query Manager and SQL Developer Kit licensed program – but it does help.

    The client may or may not be required to have some kind of SQL product depending on the client. Typically, a PC client will use an ODBC driver or the Client Access SQL APIs to establish the SQL link to the server's database.

    Stored procedures come in two flavors

    There are two types of stored procedures, external stored procedures and SQL stored procedures. External stored procedures are created using any of the standard iSeries programming languages (e.g., C, COBOL, RPG, etc.). You simply create a program that does what you need. It does not have to contain embedded SQL statements, but it certainly can. Once the program is created, you make a stored procedure from it using the Create Procedure SQL statement.

    SQL stored procedures are created using just SQL. Again, you use the Create Procedure SQL statement, but instead of referring to an external program as you would with an external stored procedure, you enter the SQL statement(s) that constitute the procedure as part of the Create Procedure SQL statement. (SQL stored procedures are created using only SQL, so you obviously have to use SQL.)

    Why use stored procedures

    Stored procedures are used primarily to increase efficiency in two ways: One, eliminating the downloading of temporary data and tables; and two, reducing the amount of overhead on the network. Consider the following case.

    Case 1: Relocating a series of SQL statements to decrease network message flows. A client sends a fixed series of SQL statements to the server, repeatedly. Every instruction must be transmitted, received, executed, and returned independently. For example, as part of its initialization, a client application creates a group of temporary files on the server. A series of Create Table statements is executed from the client application each time the program is called. Each statement is transmitted independently and, thus, produces inefficiencies.

    This situation is easily improved by simply removing the series of Create Table statements from the client application and embedding them in a program on the server. The client then uses the SQL Call statement like the following to execute the stored procedure program.

    Call SQLInit ()

    -- where SQLInit is the name of the program on the server. The empty set of parentheses indicate that there are no parameters.

    In the next installment, we'll consider a different situation where stored SQL procedures can help. We'll also explore some more examples and some other aspects of using stored procedures.

    -----------------------------------
    About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.


    Rate this Tip
    To rate tips, you must be a member of Search400.com.
    Register now to start rating these tips. Log in if you are already a member.


    Submit a Tip




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    iSeries administrator tips
    Analyze the health of your IBM i server with iScore
    Researching high availability for your System i shop
    Translating Linux for IBM i admins: Using GUI to make it easy
    Translating Linux for IBM i admins: Working with jobs and networking
    OpenOffice: What to know before making the transition from Microsoft Office
    OpenOffice: An enterprise open source solution
    Database performance comparisons on IBM i
    Translating Linux for IBM i admins: User profile commands
    Modern System i reports using Client Access
    Tips for installing Lotus Domino server on a System i partition

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



  • iSeries Security - Security Tools, Physical Security and System Security
    HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts