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

Count No. Of columns


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Thu Sep 22, 2011 1:37 pm
Reply with quote

Hi,

Could someone tell the query to find count of columns in a table.
Like in ORACLE there is something call DESC <table_name>

For Ex.
SELECT * FROM SYSIBM.SYSPLAN;
How can we find out as to how many columns above query will fetch?

Regards,
N
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Sep 22, 2011 2:03 pm
Reply with quote

Quote:
SYSIBM.SYSTABLES table

Quote:
COLCOUNT : Number of columns in the table or view. The value is 0 if the row describes an alias.

publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Fzclumns.htm
Back to top
View user's profile Send private message
cmsmoon

New User


Joined: 17 Jun 2010
Posts: 75
Location: Chennai

PostPosted: Tue Nov 15, 2011 7:38 pm
Reply with quote

Hi ,

You can use the below query to get no of columns in a table.


SELECT COUNT(NAME)
FROM SYSIBM.SYSCOLUMNS
WHERE TBNAME = 'table name'
AND TBCREATOR = 'table qualifier';
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Nov 15, 2011 7:56 pm
Reply with quote

though the link was bad for Gnana Sekaan Nallathambi's post
the systables route seems to be a better piece of sql than
yours cmsmoon.

his is a one row, one column fetch,
yours is a multirow fetch with a scalar function.

by the way, the term fetch is used as is by ibm when referring to row retrieval,
not a cursor.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Nov 15, 2011 9:21 pm
Reply with quote

DESCRIBE

Including dynamic SQL for varying-list SELECT statements in your program
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 To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top