IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Select Into statement with Union


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nithya.U.M
Warnings : 1

New User


Joined: 11 Nov 2008
Posts: 21
Location: India

PostPosted: Fri May 15, 2009 8:45 pm
Reply with quote

We have two tables say Tab1 and Tab2. I need to use a select query which is an union of these tables and move the values into DCLGEN fields.Since the output would fetch only one record at a time which would be present in either of the tables i need to use a "select into" statement instead of a cursor.I have coded it as follows and would like to have an opinion on whether i have implemented the Into and Union correctly as we were not receiving the desired results after the implemetation.

Select col1, col2
from tablea
union
select col1, col2
into
:ws-col1,
:ws-col1
from tableb
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri May 15, 2009 8:56 pm
Reply with quote

maybe because you are stuffing everything into the same host variable WS-COL1? also, the syntax does not seem to be correct.

If you want help, stop 'editing your sql' and cut & paste the sql into bbcode.
Unless of course you did cut &paste, which means that my first suggestion may be a place to start.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Dynamically pass table name to a sele... DB2 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top