Q:

Getting a strange syntantical error in db2 for sql query

I am running this query in db2: 
with closure (obj_1, obj_2) as (SELECT distinct t.obj_1, t.obj_2 FROM temp4 t
UNION ALL SELECT c.obj_1, t.obj_2 FROM closure c, temp4 t WHERE c.obj_2=t.obj_1)

I keep getting this error and I'm not sure how to fix it since the unexpected token IS the expected token?:
SQL0104N  An unexpected token ")" was found following "HERE c.obj_2=t.obj_1".  
Expected tokens may include:  ")".  SQLSTATE=42601

A:

You are using a Common Table Expression (CTE) only - the SELECT for the CTE is missing (in addition to the comment from D Stanley.
So check out something like this:
with closure (obj_1, obj_2) as (
 SELECT distinct t.obj_1, t.obj_2 
   FROM temp4 t
 UNION ALL 
 SELECT c.obj_1, t.obj_2 
   FROM closure c, temp4 t 
   WHERE c.obj_2=t.obj_1)
SELECT * FROM closure

