简体   繁体   中英

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

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM