MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

union in stored procedure
Goto page Previous  1, 2
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
wishlister
Beginner


Joined: 08 Mar 2007
Posts: 16
Topics: 3

PostPosted: Thu Mar 08, 2007 2:00 pm    Post subject: Reply with quote

http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0506melnyk/
under listing 3.
that's what im trying..
i want to combine salesperson and engineer tables in one table with their respective column fields. and if the column does not apply to them, it will be left as blank.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Mar 08, 2007 2:51 pm    Post subject: Reply with quote

wishlister,

You are very poor at explaining as to what you are trying to do. In the link(listing 3) given there are no columns named rate or hrs or the tables HR or MIS. How are we supposed to help you ?

As I mentioned earlier show us the column defintions of tables HR and MIS and also the target table which you are trying to insert these values into.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
wishlister
Beginner


Joined: 08 Mar 2007
Posts: 16
Topics: 3

PostPosted: Thu Mar 08, 2007 4:23 pm    Post subject: Reply with quote

create type EMP as
(empno char(6),
name varchar(50),
dtype varchar(11))
ref using integer
mode db2sql

create type HR under EMP as
(rate decimal(9,2),
hrs decimal(9,2))
mode db2sql

create type MIS under EMP as
(sal decimal(9,2),
bonus decimal(9,2))
mode db2sql

create table EMP_t of EMP
(ref is OBJID user generated,
EMPNO with options not null)

create table HR_t of HR
under EMP_t
inherit select privileges

create table MIS_t of MIS
under EMP_t
inherit select privileges

create table employees
(empno char(6) not null,
name varchar(50) not null,
dtype varchar(11) not null,
rate decimal(9,2),
hrs decimal(9,2),
sal decimal(9,2),
bonus decimal(9,2),
primary key(empno))
Back to top
View user's profile Send private message
wishlister
Beginner


Joined: 08 Mar 2007
Posts: 16
Topics: 3

PostPosted: Thu Mar 08, 2007 7:11 pm    Post subject: Reply with quote

how will i join the two tables(MIS_t and HR_t) in one table
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri Mar 09, 2007 10:31 am    Post subject: Reply with quote

wishlister,

You don't need an union to just insert rows from 2 tables into a single table. try this

Code:

INSERT INTO EMPLOYEE (SELECT A.EMPNO               
                            ,A.NAME               
                            ,A.DTYPE               
                            ,A.RATE               
                            ,A.HRS                 
                            ,B.SAL                 
                            ,B.BONUS               
                        FROM HR_T   A             
                            ,MIS_T  B             
                       WHERE A.EMPNO   = B.EMPNO   
                         AND A.NAME    = B.NAME); 


Please stop creating more topics for the same problem.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group