Newsletters Subscriptions Forums Media Kit About Us Contact Search Home

mgo
OS/400 Edition
Volume 3, Number 67 -- October 3, 2003

More Query/400 and Date Selection Techniques


Dear Readers:

I know many of you are stuck with Query/400, in spite of the facts that IBM apparently never got around to finishing it and that there is an abundance of better query packages on the market. So I enjoy running the tips I receive from Bob Ellsworth, the man who makes Query/400 go where it has never gone before. Today I am pleased to present some alternatives to one of Bob's recent tips. I hope they may be of help in the daily struggle.

--Ted

Hey, Ted:

I am surprised you haven't suggested a much easier solution than the one Bob presented. Use an SQL view! The following command creates a view that matches Bob's example.

CREATE VIEW xxx/TODAYSDATE as SELECT 
CURRENT DATE as TODAY, 
CURRENT DATE-1 DAY as YESTRDY, 
CURRENT DATE-7 DAYS as LASTWK, 
CURRENT DATE+3 MONTHS as NEXT3M 
FROM QSYS2/QSQPTABL

--Yannick

Hey, Ted:

Here's a trick I use for dates in SQL. I create a lot of SQL statements in a source library and then use RUNSQLSTM to execute so that's the context of the insert. You only need to run this once to create a view. The DROP statement is for making changes.

drop view bobsqrys/qtoday; 
   
 -- you can format to suit

create view bobsqrys/qtoday as 
 select ((year(curdate())*10000)+ 
         (month(curdate())*100)+ 
         (day(curdate()))) as today, 
        ((year(curdate()-1 day)*10000)+ 
         (month(curdate()-1 day)*100)+ 
         (day(curdate()-1 day))) as ystrday, 
        ((year(curdate()-7 day)*10000)+ 
         (month(curdate()-7 day)*100)+ 
         (day(curdate()-7 day))) as lstweek, 
        ((year(curdate()-3 month)*10000)+ 
         (month(curdate()-3 month)*100)+ 
         (day(curdate()-3 month))) as thremth 
 from qsys2/qsqptabl

--Bob

Hey, Ted:

Why do you need the date file and the join logic? Use the current(date) function. Calculate other dates based on today and use that for selection. Here are some of the date expressions from a query I created several years ago to demonstrate query date functions.

Field       Expression                         Column Heading
=========   ================================   ==================
YEAR_AGO    current(date) - 1 year             One year ago

TOMORROW    char(current(date) + 1 day, iso)   Tomorrow    

FIRST       current(date) + 1 day -            First day of month 
            day(current(date)) day                                

LAST        current(date) + 1 month -          Last day of month  
            day(current(date)) day

Thanks to all of you for these tips. I feel confident that many readers will find them helpful.

Bob's technique would still be needed to handle dates of unsupported types, such as the Julian format. Joining to a file can also be cleaner than including a lot of messy calculations. I have joined to a file of dates many times and have found that technique very helpful.

--Ted


Sponsored By
GST

AIT Backup for iSeries

GST, Inc.
Phone: 866-478-4621 or 949-900-1090 (for sales x 300)
Web: http://www.gstinc.com
Email: sales@gstinc.com

---------------------------------------------------------------------

SUMMARY

Compact, modular and reliable backup solution at unbeatable prices

· Powerful 3lb drive in small form factor
· LCD module for backup effiency
· Capacity up to 260GB
· Speed up to 112GB/hour
· LVD, HVD, and fibre connectivity
· Starts at $2,000 USD

---------------------------------------------------------------------

THE BIG PICTURE

· A single AIT tape drive in external, modular, stackable enclosure.
· Capacity: AIT-3 100GB native (260 GB compressed).
· Speed: AIT-3 43GB/hour native (112GB/hour compressed).
· Single subsystem is field-upgradeable to dual drive subsystem.
· LCD display panel improves backup efficiency.
· Supports AIT-1, AIT-2 and AIT-3.
· Roadmap to AIT-4, AIT-5, AIT-6.
· AIT range: single drive to enterprise-wide libraries.
· Supports LVD and HVD SCSI connections directly.
· Supports Fibre Channel via our bridges and routers.

The Single AIT Tape Subsystem is part of GST's EntryDR™ family. Single AIT Tape Subsystems are housed in upgradeable modular enclosures. This subsystem delivers high-performance and high reliability at cost-effective pricing to meet basic backup needs for the small to medium range of servers.

Building-block modularity enables the Single AIT Tape Subsystem to be upgraded to GST's Dual AIT Tape Subsystem to strengthen disaster recovery protection. An LCD panel provides an advanced operator interface for visibility over the backup operation.

The Single AIT Tape Subsystem can backup IBM eServer family members: iSeries, pSeries and xSeries servers. They connect natively with LVD (low voltage differential) and HVD (high voltage differential) SCSI connections, and with Fibre Channel (FC) through our BridgeLink™ family of bridges and SanMatrix™ family of routers. Model overview.

GST's Single AIT Tape Subsystem is available in a variety of models. Each AIT technology (AIT-1, AIT-2, AIT-3) is available in two server-to-SCSI Adapter interfaces:

LOW VOLTAGE DIFFERENTIAL (LVD). Connectivity with eServer family. iSeries uses IBM SCSI Adapter feature code: FC 5702, 5705. pSeries and xSeries servers use a variety of LVD SCSI adapters.

HIGH VOLTAGE DIFFERENTIAL (HVD). Connectivity with eServer family. iSeries uses IBM SCSI Adapter feature code: FC 2729, 2749, 6501, 6534. pSeries and xSeries servers use a variety of HVD SCSI adapters.

AIT TECHNOLOGY

AIT tape technology has evolved through three generations: AIT-1, AIT-2 and AIT-3 and provides outstanding capacity and performance with a highly stable technology roadmap. AIT cartridges utilize Memory-in-Cassette (MIC) architecture providing rapid time-to-data and multiple load points for partitioning data.

Native cartridge capacities for AIT-1, AIT-2 and AIT-3 are 35GB, 50GB and 100GB (91GB, 130GB, 260GB compressed) with speeds of 14GB/hour, 22GB/hour and 43GB/hour (37GB/hour, 56GB/hour and 112GB/hour compressed). Scalability is planned to a 6th generation product with native capacity of 800GB (2TB compressed) and a speed of 345GB/hour (900GB/hour compressed). A 2-to-1 compression ratio is achieved with Adaptive Lossless Data Compression (ALDC) technology.

KEY BENEFITS

DUAL DRIVE UPGRADE - A second modular drive and controller can be added later to upgrade to a Dual AIT Tape Subsystem as backup needs evolve that require DR protection, fault tolerant backup or greater unattended backup capacity.

HARDWARE INVESTMENT PROTECTION - The modular design of the Single AIT Tape Subsystem protects user investment by permitting the original single drive unit to be retained unmodified as part of the upgraded Dual AIT Tape Subsystem.

SPACE SAVER - The small dimensions and weight of the modular configurations facilitate the optimum use of datacenter space.

MEDIA INVESTMENT PROTECTION - For IT sites with an investment in AIT-1 media and drives, the newer AIT-2 and AIT-3 technologies are backward-read compatible, and forward-read compatible to future generations.

SERVICEABILITY - Modularity of design permits individual drives to be easily replaced in building-block fashion by the user.

KEY FEATURES

STACKABLE ENCLOSURES - Individual modular enclosures enable each drive and the mirrored backup controller to be handled as separate building blocks; facilitates field upgrade from single to dual drives.

LCD DISPLAY PANEL - Multi-function LCD continuously displays drive and backup status.

CONVENIENT DRIVE INTERFACE - RS232 interface for updating firmware and optimizing drive performance.

SERVICE AND SUPPORT - A variety of support programs provide installation and onsite service; includes GST's Accelerated Ship Program (GASP) to get replacement units on the scene rapidly.

WARRANTY - Purchase price includes a built-in manufacturer's warranty of three years.

GST, Inc.
Phone: 866-478-4621 or 949-900-1090 (for sales x 300)
Web: http://www.gstinc.com
Email: sales@gstinc.com



THIS ISSUE
SPONSORED BY:

GST
WorksRight Software


BACK ISSUES

TABLE OF
CONTENTS

More Query/400 and Date Selection Techniques

Updating through a Join with SQL

Reader Feedback and Insights: What's a Korn Shell?


Editors
Howard Arner
Joe Hertvik
Ted Holt
David Morris
Shannon O'Donnell

Managing Editor
Shannon Pastore

Publisher and
Advertising Director:

Jenny Thomas

Advertising Sales Representative
Kim Reed

Contact the Editors
Do you have a gripe, inside dope or an opinion?
Email the editors:
editors@itjungle.com

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.