column number in syscolumns table
Posted in 2004
Topics: General Discussion
greetings if i have a tabname from systables (say it's tabid is 150 and it's tabname is stakeholder) and i go look up tabid of 150 in the syscolumns table, there is also a field in syscolumns called Colno - how do i get the datatype that is represented by this Colno in another system table (i am assuming there is one that will tell me this) ? thanks,Tom
Three places to look spring to mind 1 the manual 2 www.oninit.com/scripts 3 www.iiug.org tomL wrote: > > greetings > if i have a tabname from systables (say it's tabid is 150 and it's > tabname is stakeholder) and i go look up tabid of 150 in the > syscolumns table, there is also a field in syscolumns called Colno - > how do i get the datatype that is represented by this Colno in another > system table (i am assuming there is one that will tell me this) ? > > thanks,Tom -- Paul Watson # Oninit Ltd # Growing old is mandatory Tel: +44 1436 672201 # Growing up is optional Fax: +44 1436 678693 # Mob: +44 7818 003457 # www.oninit.com #
"tomL" <tomcaml@yahoo.com> wrote > greetings > if i have a tabname from systables (say it's tabid is 150 and it's > tabname is stakeholder) and i go look up tabid of 150 in the > syscolumns table, there is also a field in syscolumns called Colno - > how do i get the datatype that is represented by this Colno in another > system table (i am assuming there is one that will tell me this) ? the datatype of the column is in syscolumn itself. It is called coltype. It is a smallint value and the definition of each value can be found in ESQL include file sqltypes.h. A sample of it is pasted below #define SQLCHAR 0 #define SQLSMINT 1 #define SQLINT 2 #define SQLFLOAT 3 #define SQLSMFLOAT 4 #define SQLDECIMAL 5 #define SQLSERIAL 6 #define SQLDATE 7 #define SQLMONEY 8 #define SQLNULL 9 #define SQLDTIME 10 #define SQLBYTES 11 #define SQLTEXT 12 #define SQLVCHAR 13 #define SQLINTERVAL 14 #define SQLNCHAR 15 #define SQLNVCHAR 16 #define SQLINT8 17 #define SQLSERIAL8 18 #define SQLSET 19 #define SQLMULTISET 20 #define SQLLIST 21 #define SQLROW 22 #define SQLCOLLECTION 23 #define SQLROWREF 24 #define SQLUDTVAR 40 #define SQLUDTFIXED 41 #define SQLREFSER8 42 #define SQLLVARCHAR 43 #define SQLSENDRECV 44 #define SQLBOOL 45 #define SQLIMPEXP 46 #define SQLIMPEXPBIN 47 #define SQLUDRDEFAULT 48 #define SQLMAXTYPES 49
tomL wrote: > greetings > if i have a tabname from systables (say it's tabid is 150 and it's > tabname is stakeholder) and i go look up tabid of 150 in the > syscolumns table, there is also a field in syscolumns called Colno - > how do i get the datatype that is represented by this Colno in another > system table (i am assuming there is one that will tell me this) ? The 'coltype' column within the syscolumns table defines the data type for the column. The data type is represented by a smallint. See the Guide to SQL: Reference for a breakdown of the smallint --> data type. You can also find this in the sqltypes.h file (it should be in one of the directories under $INFORMIXDIR/incl - either esql or public). In addition, there were a couple of threads on this at c.d.i. within the past year or so. You could try an 'Advanced Groups Search' at Google using both 'syscolumns' and 'coltype' as your search criteria. Some of the others posted scripts or referenced tools available at the IIUG site to assist with this. I don't believe those data types are defined by name in any of the system tables. -- June Hunt
tomcaml@yahoo.com (tomL) wrote in message news:<3158a6a2.0402030742.1fcf4dc4@posting.google.com>...
> greetings
> if i have a tabname from systables (say it's tabid is 150 and it's
> tabname is stakeholder) and i go look up tabid of 150 in the
> syscolumns table, there is also a field in syscolumns called Colno -
> how do i get the datatype that is represented by this Colno in another
> system table (i am assuming there is one that will tell me this) ?
>
> thanks,Tom
ColNo is the entry order of the fields in the table as in
create table t_test(
This_is_colNo_1 serial,
this_is_colNo_2 integer,
this_is_colno_3 char(1),
this_is_colno_4 varchar(2),
this_is_colno_5 text
) ;
What is important is the coltype field. I can't remember the values
for each field type, but I always just figure them out if I need them.
Create a table like the one above then look at the coltypes. Also
create some fields with not null constraints because I think the
coltype field changes to 255 minus coltype of nullable field.