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
 

 

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 SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm


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