fhg
Volume 7, Number 2 -- January 17, 2007

Gotcha Lurking in Datalink File Manager for DB2/400

Published: 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


Sponsored By
SEQUEL

SEQUEL can be used for
virtually ALL business intelligence functions
on the System i, including:

                                                    · Executive Dashboards
                                                    · Graphical Query & Reporting
                                                    · Drill-Down Data Analysis
                                                    · Multi-Platform Database Support
                                                    · E-Mail Report and File Distribution
                                                    · Secure Web Access

SEQUEL is the single solution for all
your business intelligence needs.

www.helpsystems.com


Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

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


The Four Hundred
Zend Core for i5/OS Ships for OS/400 V5R3

Why the Number of Women in IT Is Decreasing

Next Generation ERP and the Rise of the Agile Organization

Mad Dog 21/21: Between y o u and i

The Linux Beacon
Red Hat Consolidates Fedora Core and Extras Development

Penguin Hatches Bare-Bones Altus Opteron Server

Why the Number of Women in IT Is Decreasing

Mad Dog 21/21: Between y o u and i

Four Hundred Stuff
IBM Patches Security Flaw in OS/400 V5R3

LXI Partners with FalconStor for VTL

Lawson Brings EMEA EAM App to the U.S.

Seagull Relaunches Farabi Tool Under BlueZone Name

Big Iron
The IT Analysts Make Their 2007 Predictions

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
January 13, 2007: Volume 9, Number 2

January 6, 2007: Volume 9, Number 1

December 30, 2006: Volume 8, Number 50

December 23, 2006: Volume 8, Number 49

December 16, 2006: Volume 8, Number 48

December 9, 2006: Volume 8, Number 47

The Windows Observer
Microsoft Unveils Windows Home Server

Patch Tuesday Yields Four Patches for 10 Vulnerabilities

Microsoft Refreshes 'Longhorn,' Delivers First 'Centro' Beta and 'Cougar' CTP

As I See It: Predictions and Poetry

The Unix Guardian
HP Readies HP-UX 11i v3 For Launch

Arrow Buys Agilysys' IT Distribution Business for $485 Million

Sun Adds Opteron Rev F Blade Server, Sets Utility Pricing

As I See It: Sweating the Little Stuff

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

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

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
Re-entrant code

Tar on qsh corrupting jar files

Starting the Qinter Subsystem

IWS1611 on CPYFRMPCD

Set Up Console Operation





 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement