[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Interactive 'WITH' Statement

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
lynn_harris
Asked:
lynn_harris
1 Solution
 
Dave FordSoftware Developer / Database AdministratorCommented:

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
 
lynn_harrisAuthor Commented:
Thank You.  I will toy with my some more.  
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now