• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Gotcha Lurking in Datalink File Manager for DB2/400

    January 17, 2007 Hey, Ted

    I’ve grown quite fond of the convenience of the DB2 SQL support in QShell, and especially the ease with which it can be invoked within a CL program, by simply calling the underlying Datalink File Manager DB2 program, QZDFMDB2. Having said that, I must also admit to getting burned by a “gotcha” lurking in this otherwise handy tool.

    Although I’ve never experienced a problem when providing QZDFMDB2 with an SQL statement in the form of a constant, I did walk straight into a real head-scratcher recently when building the parameter string for this program from variable data. I kept getting an “Invalid token” error, and the “token” was the first few characters of a variable defined in my CL immediately following the definition of the parameter being passed to QZDFMDB2. Here’s a snippet of my source to illustrate:

    DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
    DCL VAR(&TEXT) TYPE(*CHAR) LEN(50)
    ...
     CHGVAR VAR(&CMD) VALUE('create table qtemp.ampud as +
                  (select * from am2000.ampud where uduser +
                  = ' *CAT '''' *CAT &MODELUSER *TCAT '''' +
                  *CAT ') with data')
     CALL PGM(QZDFMDB2) PARM(&CMD)
    

    Now, this call worked just fine. No doubt feeling cocky at this point, I went on to execute:

    CHGVAR VAR(&CMD) VALUE('update qtemp.ampud set +
                 uduser = ' *CAT '''' *CAT &NEWUSER *TCAT +
                 '''' *CAT ', udtext = ' *CAT '''' *CAT +
                 &TEXT *TCAT '''')
    CALL PGM(QZDFMDB2) PARM(&CMD)
    

    Well, the walls came a-crashing at that point, with the aforementioned token error. I tried increasing the length of my &CMD parameter, to 2000. No luck. I tried 5000. Nope. I tried moving the Declare of &CMD to the end of the variables. Zippo. At that point there must have been a divine intervention, for it occurred to me to add a semicolon terminator to my SQL statement. Voilà! Here’s the simple change:

    CHGVAR VAR(&CMD) VALUE('update qtemp.ampud set +
                 uduser = ' *CAT '''' *CAT &NEWUSER *TCAT +
                 '''' *CAT ', udtext = ' *CAT '''' *CAT +
                 &TEXT *TCAT ''';')
    

    Apparently the SQL processor just keeps sifting through all those trailing blanks in my parameter, and trudges right into whatever variable gets in its way. I haven’t tried setting the length to 65,535 or 32,767 or whatever IBM may have set the boundaries to, but I think I’ll just always include a terminator to be safe. Of course, that’s when I remember to! 🙁

    By the way, as for the first statement executing without error, my guess is that “with data” satisfied the SQL processor as the last “tokens” expected in that syntax, whereas my update statement could have continued–after 4000 spaces! Yeah, I like a little white space in the middle of my code.

    –Jim Rothwell, NBC Universal



                         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
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    BCD:  Try WebSmart - the easiest and most complete iSeries Web development tool
    COMMON:  Join us at the 2007 conference, April 29 – May 3, in Anaheim, California
    New Generation Software:  Leading provider of iSeries BI and financial management software

    IBM to Open Eight SOA Centers Worldwide Big Blue Readies Revamped Storage for the System i

    Leave a Reply Cancel reply

Volume 7, Number 2 -- January 17, 2007
THIS ISSUE SPONSORED BY:

WorksRight Software
SEQUEL
Patrick Townsend & Associates

Table of Contents

  • Using APIs to Send Impromptu Messages, Take Two
  • Gotcha Lurking in Datalink File Manager for DB2/400
  • Admin Alert: Ending Subsystems Properly

Content archive

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

Recent Posts

  • The Power11 Transistor Count Discrepancies Explained – Sort Of
  • Is Your IBM i HA/DR Actually Tested – Or Just Installed?
  • Big Blue Delivers IBM i Customer Requests In ACS Update
  • New DbToo SDK Hooks RPG And Db2 For i To External Services
  • IBM i PTF Guide, Volume 27, Number 33
  • Tool Aims To Streamline Git Integration For Old School IBM i Devs
  • IBM To Add Full System Replication And FlashCopy To PowerHA
  • Guru: Decoding Base64 ASCII
  • The Price Tweaking Continues For Power Systems
  • IBM i PTF Guide, Volume 27, Numbers 31 And 32

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