Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Select Into statement with Union

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Select Into statement with Union
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: 6968
Location: porcelain throne

PostPosted: Fri May 15, 2009 8:56 pm    Post subject:
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    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 WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts ON 2 AND EVERY 1 - Statement ??? UmeySan COBOL Programming 2 Tue Jul 25, 2017 1:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us