Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
how to get the coloumns of a table in a horizontal way

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
kalinga

New User


Joined: 25 May 2005
Posts: 4
Location: chennai,india

PostPosted: Tue May 31, 2005 12:54 pm    Post subject: how to get the coloumns of a table in a horizontal way
Reply with quote

hi,

say i'm having a table called EMP_TABLE, in that the columns are emp_id,sal,name,loc.

EMP_DEP HAS SOME COLUMNS

i am executing the query USING CURSOR SELECT * FROM EMP_TABLE, EMP_DEP. I WANT TO GET THE ANSWER LIKE BELOW


EMP_TABLE 100 9999 xyz mum
EMP_DEP 92K RUBBER SOFA
EMP_TABLE 200 8888 zyx chn
EMP_DEP 34S STEEL BUS
AND SO ...............ON
Back to top
View user's profile Send private message
References
vasanthanc

Active User


Joined: 01 Apr 2005
Posts: 59

PostPosted: Tue May 31, 2005 1:59 pm    Post subject:
Reply with quote

But why do you want the table name in your result, that to when u r using cursor ?
Lets come to your question. How do you compare which emp belongs to which department? There should be a common field. (i.e) there should be a field in emp_table like emp_dept_no and similar field should be there in emp_dep table also. then u can write the query as

Select * from Emp_Table, Emp_Dept
where EMP_TABLE.EMP_DEPT_NO = EMP_DEP.DEPT_NO

I think, this is what you needed (?)
Back to top
View user's profile Send private message
MGIndaco

Moderator


Joined: 10 Mar 2005
Posts: 478
Location: Milan, Italy

PostPosted: Tue May 31, 2005 3:18 pm    Post subject:
Reply with quote

If you are running a Cobol program you can have your columns in the way you need. If you use a DCL and you fetch with your coursor you can establish the direction of data and name of columns.

But if you need display the same information as the sample above in QMF you must use a most complex query that needs information NAME from the SYSIBM.SYSCOLUMNS.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1