fhg
Volume 8, Number 10 -- March 12, 2008

More About SQL Correlation Names

Published: March 12, 2008

Hey, Ted:

I hope my question is an easy one to answer. I have a file that stores the location of inventory in a warehouse. Location consists of a row (an aisle), column, and level. Why will an SQL UPDATE let me change the column and level, but not the row?

--Scott


You can update the column like this:

update qtemp/inventory 
   set column=4        
 where item = 'SL-701'

But updating the row gives you error SQL0104. (Token 4 was not valid. Valid tokens: ( : DAY CAST CHAR DATE DAYS HOUOUR LEFT TIME TRIM YEAR COUNT MONTH.)

update qtemp/inventory 
   set row=4           
 where item = 'SL-701'

SQL doesn't let you change the row because the field is named ROW, which has a reserved meaning in the SET clause of the UPDATE command. You'll need to use a correlation name so SQL will know that you mean the ROW column (field) in the inventory file.

update qtemp/inventory as inv 
   set inv.row=4              
 where item = 'SL-701'        

Another predefined value that has bitten me on more than one occasion is USER, which refers to the user profile under which the query is running. Let's assume that MYFILE has a field called USER, which stores the name of the user who last wrote or updated a record. What does the following query do?

select * from myfile 
 where user = 'DAN'  

If the user running the query is DAN, the SELECT returns all the rows (records) in MYFILE. Otherwise, the query returns an empty set.

To select the records that were last modified by DAN, do this instead.

select * from myfile as x 
 where x.user = 'DAN'     

--Ted


RELATED STORY

Good Reasons to Use Unrequired Correlation Names



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


Sponsored By
PROFOUND LOGIC SOFTWARE

Need Results Fast?
Web-enable with Genie!

                                                          · Easy Installation
                                                          · Codeless Customizations
                                                          · Instant Results

With Genie on your side, you can be
modernized in less than a day. Simply
install, customize, and deploy.

See the magic of Genie today.

Download a FREE 30-day trial at
www.profoundlogic.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

MoshiMoshi:  An Interactive Experience for the System i Community. Coming March 30.
COMMON:  Join us at the annual 2008 conference, March 30 - April 3, in Nashville, Tennessee
Vision Solutions:  Disaster Recovery and Compliance – Get the Free e-Book!


 

IT Jungle Store Top Book Picks

Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
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


 
The Four Hundred
IBM Readies Big Power6 Boxes, New X64 Servers

System i Security: Lots of Room for Improvement

Server Virtualization and Consolidation Require More Resiliency

Thermometer Money: Changing a Business Partner Paradigm

Arrow Buys French Midrange Distributor

The Linux Beacon
AMD Says Barcelona Bug Is Fixed, Almost Ready to Ramp

HPC Sales Account for Most of 2007's Server Sales Growth

IBM Readies Big Power6 Boxes, New X64 Servers

Canonical Ships Landscape System Management Tool for Ubuntu

Surf's Up for Web-Based Organized Crime, IBM X-Force Says

Four Hundred Stuff
Solidcore Supports i5/OS with Real-Time Change Control

Vision to Support IBM's HASM Technology in Clustering Software

CodeGear Offers a Rational Alternative for System i Development

TDCI Hooks Product Configurator into i5/OS ERP

Fax Added to System i VoIP Solutions

Big Iron
Making the Case for System z10 Server Consolidation

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
March 8, 2008: Volume 10, Number 10

March 1, 2008: Volume 10, Number 9

February 23, 2008: Volume 10, Number 8

February 16, 2008: Volume 10, Number 7

February 9, 2008: Volume 10, Number 6

February 2, 2008: Volume 10, Number 5

The Windows Observer
Ballmer Shrugs Off $1.4 Billion Fine from EU

Linux and Windows Server Sales Outpace the Market in Q4

Microsoft Touts Speed, Simplicity of Windows Server 2008

SMBs Get the MOS Attention From Microsoft

Yahoo Says Microsoft Bid is Hurting Business

The Unix Guardian
AMD Says Barcelona Bug Is Fixed, Almost Ready to Ramp

Linux and Windows Server Sales Outpace the Market in Q4

MetaRAM Quadruples DDR2 Memory Capacity in Servers

Mad Dog 21/21: Plane's Peeking

Infinite Software Partners with HP, Acquires Altos Technology Group

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

THIS ISSUE SPONSORED BY:

WorksRight Software
Profound Logic Software
Guild Companies


Printer Friendly Version


TABLE OF CONTENTS
Detect Host OS and Client Version Levels within Client Software

More About SQL Correlation Names

Admin Alert: A Much Quicker Way to Move System i Objects Between Partitions

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
Data Type *DEC in MSGF

How to identify when the OS upgrade was performed ???

FTP in arrival sequence

S36 environment problem

QSH won't write in batch!





 
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