bigdata123
bigdata123

Reputation: 473

SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=SYSCAT.COLUMNS, DRIVER=3.54.54

Hi i'm trying to find column count for a db2 table. I have schema name and table name details. Tried with

select COUNT(*) from SYSCAT.COLUMNS  WHERE TABNAME = 'ABC' and TABSCHEMA='XYZ'

AND

SELECT COUNT(*) FROM sys.columns WHERE object_id = OBJECT_ID('ABC')

But unfortunately both of them are throwing errors.

Need suggestions with my issue of finding column count for a table in db2 database

Upvotes: 0

Views: 3960

Answers (2)

Esperento57
Esperento57

Reputation: 17492

this code work on system i (AS400...)

 select * from qsys2.syscolumns                              
 where COLUMN_NAME='YOURCOLUMNNAME'                          
 and TABLE_NAME='YOURTABLENAME' and TABLE_SCHEMA='YOURLIB'   

Upvotes: 0

bigdata123
bigdata123

Reputation: 473

Hi finally i was able to fix this issue by modifying my query to

select count(*) from sysibm.syscolumns where tbname = 'ABC' and TBCREATOR = 'XYZ'

where TBCREATOR is the schema name and tbname is the table name.

Upvotes: 1

Related Questions