• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 446
  • Last Modified:

How to retrieve FieldLength

How can I retrieve the length from a field on an iSeries machine.

I use a odbc to connect and then SQL statements (ADO Query)
0
pucko
Asked:
pucko
2 Solutions
 
puckoAuthor Commented:
What I mean with fieldlength is That I want to check the "definition" of the field. Not the length of the data in the field. (I need to know what is the max length of a string that I can put in a field)
0
 
Jerryuk007Commented:
In MSSQL, you can use something like:
select object_name(id)as TableName,* from syscolumns where object_name(id)='<YourTableName>'

You could of course add a JOIN to systypes to get the name of the type...

Jerry
0
 
puckoAuthor Commented:
That is in Mssql.

I think I have solved my problem temporary by using checking TADOQuery.Fields[ix].Size;
But would be great to do it with an SQL statement against the DB2
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi pucko,

Perhaps the easiest is to query the view SYSIBM.COLUMNS.

Depending on the datatype and exactly what you want, you could want the data from CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, or several other fields.



Good Luck,
Kent

SELECT *
FROM sysibm.columns
WHERE table_name = 'mytable'
  AND table_schema = 'myschema'
  AND column_name = 'mycolumn';

Open in new window

0
 
MurpheyApplication ConsultantCommented:
Hi Pucko,

From the AS/400 you can also query or sql the table QADBXREF in library QSYS, there you find all fields with specs from all files from all libraries.

Just take a look.

Regards,
Murph
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now