Interactive 'WITH' Statement

Posted on 2009-05-14
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

Question by:lynn_harris
LVL 18

Accepted Solution

daveslash earned 50 total points
ID: 24390015

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


  SELECT 2523 as DDDRV#,

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

  from   sysibm/sysdummy1)

select *

from   MYTABLE

where  dddrv#=2523

  and  strdate = '2009-03-16'



Open in new window


Author Closing Comment

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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mySQL Syntax 7 34
How to get the following query to show decimals 3 28
xpath sql query 2008 8 44
Get Duration of last Status Update 4 32
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

23 Experts available now in Live!

Get 1:1 Help Now