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)
LVL 1
puckoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Operating Systems

From novice to tech pro — start learning today.