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: 6968
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm

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