Solved

Interactive 'WITH' Statement

Posted on 2009-05-14
2
174 Views
Last Modified: 2012-05-07
Sample code not working and I don't see why.  Any suggestions?
Token ( was not valid. Valid tokens: FOR WITH FETCH ORDER UNION EXCE 

 WITH MYTABLE AS (SELECT DDCREW, DDDRV#,                              

   DATE(DDYEAR || DDMOTH || DDDAY) As strdate, ddmd from cdsddm)      

 select * from MYTABLE                                                

   where dddrv#=2523                                                  

    and strdate = 20090316

Open in new window

0
Comment
Question by:lynn_harris
2 Comments
 
LVL 18

Accepted Solution

by:
daveslash earned 50 total points
ID: 24390015

Since my date-format is *ISO, the following works for me:


WITH MYTABLE AS (

  SELECT 2523 as DDDRV#,

         DATE('2009' || '-' || '03' || '-' || '16') As strdate

  from   sysibm/sysdummy1)

select *

from   MYTABLE

where  dddrv#=2523

  and  strdate = '2009-03-16'
 

HTH,

DaveSlash

Open in new window

0
 

Author Closing Comment

by:lynn_harris
ID: 31581707
Thank You.  I will toy with my some more.  
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle PL/SQL syntax 4 52
Access Query concatenation 12 45
how to do this MS SQL script? 11 48
2 Access tables, count verbiage used 6 20
November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now