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
 

 

Count No. Of columns

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Count No. Of columns
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: 785
Location: Chennai, India

PostPosted: Thu Sep 22, 2011 2:03 pm    Post subject:
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.

http://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: 72
Location: Chennai

PostPosted: Tue Nov 15, 2011 7:38 pm    Post subject: Reply to: Count No. Of columns
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    Post subject:
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: 1278
Location: Belgium

PostPosted: Tue Nov 15, 2011 9:21 pm    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Update the Sortout file with record c... karthik_sripal SYNCSORT 8 Tue May 17, 2016 8:52 pm


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