Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Unload DB2 table with a SELECT query with UNION

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
kethepalli vagdevi

New User


Joined: 07 Sep 2006
Posts: 2

PostPosted: Fri Sep 15, 2006 5:21 pm    Post subject: Unload DB2 table with a SELECT query with UNION
Reply with quote

How can I unload data from more than 1 DB2 table.
The selection creiterion is given as a SELECT query with union in the UNLOAD parameters as :

UNLOAD
UNLOADDN(SYSRE001)
SORTDEVT SYSDA
SELECT a, b,c
From table1
UNION
SELECT d,b,c
from table2,table1
where table1.b=table2.d and
table1.a=substr(d,1,3)
group by table1.a,b,c,d


It errors as "UNEXPECTED TOKEN "UNION' ENCOUNTERED'

NOTE: d is of 8 characters and a is of 3 characters

Ex: table1 -->
a b c
001 ab1 xyz
001 ab2 abc

table2: -->
d
ab100035
ab100050

Output should be like that :


a b c

001 ab1 xyz
001 ab100035 xyz
001 ab100050 xyz
001 ab2 abc
Back to top
View user's profile Send private message

MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Fri Sep 15, 2006 8:17 pm    Post subject: Re: Unload DB2 table with a SELECT query with UNION
Reply with quote

Try this setup and see if this works for you:


//STP0100 EXEC PGM=IKJEFT01,DYNAMNBR=20
//SYSREC00 DD DSN=Give dataset name for output raw data,
// DISP=(,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,99),RLSE),DCB=(MODEL.DSCB1,BLKSIZE=0)
//SYSPUNCH DD DUMMY
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBxx)
RUN PROGRAM(DSNTIAUL) PLAN(DSNTIAUL) PARMS('SQL')
END
/*
//SYSIN DD *
SELECT statement
UNION
SELECT statement
;
/*
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us