How to get the Columntypes of a tabel

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
mikesmurph
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 13.01.2010, 08:44

How to get the Columntypes of a tabel

Post by mikesmurph »

Hi,

is there a way to get the Columntypes of a Table?

I need the Types like (varchar, int, ...) of column. Can anyone help me?

Thanks

Michael
jeremicm
Senior Boarder
Senior Boarder
Posts: 61
Joined: 18.10.2006, 17:07
Contact:

Post by jeremicm »

ZQuery.Fields[].DataType should do it...
mikesmurph
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 13.01.2010, 08:44

Post by mikesmurph »

Hi jeremicm,
thanks for your help, but i need the SQL-Types not the Delphi-Types.
For Example: My Table have a Column FaxNumber an the SQL-Datatyp is Char.

Michael
Dali
Junior Boarder
Junior Boarder
Posts: 30
Joined: 08.02.2010, 14:36

Post by Dali »

I don't understand why do you need that but, correct me if I'm wrong, as every database manager uses its own SQL dialect, and Zeos tries to keep separate both kind of types, providing public access only for those you'll actually need to write an application (which are the Delphi ones), I'm afraid that the easiest way of doing that is accessing the metadata of the underlying database directly using SQL code... Which is, of course, not portable.
jeremicm
Senior Boarder
Senior Boarder
Posts: 61
Joined: 18.10.2006, 17:07
Contact:

Post by jeremicm »

You can always do SHOW CREATE TABLE tblname (for mysql, or similar for database you use) and parse result for column you need...
Post Reply