Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 788
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: 75
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: 6970
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: 1281
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
No new posts Creation of Datasets dynamically on t... Raghu M N DFSORT/ICETOOL 8 Fri Mar 16, 2018 12:56 am
No new posts help to replace columns by rows Vikas Maharnawar DFSORT/ICETOOL 8 Tue Mar 06, 2018 3:27 pm
No new posts Skip records depends on count lakshmiibmmainframes DFSORT/ICETOOL 5 Sun Dec 24, 2017 9:51 pm
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us