00001 #include <string.h>
00002 #include "dbmi.h"
00003
00010 char *
00011 db_sqltype_name(sqltype)
00012 int sqltype;
00013 {
00014 static char buf[256];
00015 int from, to;
00016
00017 switch (sqltype)
00018 {
00019 case DB_SQL_TYPE_CHARACTER: return "CHARACTER";
00020 case DB_SQL_TYPE_NUMERIC: return "NUMERIC";
00021 case DB_SQL_TYPE_DECIMAL: return "DECIMAL";
00022 case DB_SQL_TYPE_SMALLINT: return "SMALLINT";
00023 case DB_SQL_TYPE_INTEGER: return "INTEGER";
00024 case DB_SQL_TYPE_REAL: return "REAL";
00025 case DB_SQL_TYPE_DOUBLE_PRECISION: return "DOUBLE PRECISION";
00026 case DB_SQL_TYPE_DATE: return "DATE";
00027 case DB_SQL_TYPE_TIME: return "TIME";
00028 case DB_SQL_TYPE_SERIAL: return "SERIAL";
00029 }
00030 switch (sqltype & ~DB_DATETIME_MASK)
00031 {
00032 case DB_SQL_TYPE_TIMESTAMP: strcpy(buf,"TIMESTAMP "); break;
00033 case DB_SQL_TYPE_INTERVAL: strcpy(buf,"INTERVAL "); break;
00034 default: return "UNKNOWN";
00035 }
00036
00037 db_interval_range (sqltype, &from, &to);
00038
00039 switch (from)
00040 {
00041 case DB_YEAR: strcat (buf, "YEAR"); break;
00042 case DB_MONTH: strcat (buf, "MONTH"); break;
00043 case DB_DAY: strcat (buf, "DAY"); break;
00044 case DB_HOUR: strcat (buf, "HOUR"); break;
00045 case DB_MINUTE: strcat (buf, "MINUTE"); break;
00046 case DB_SECOND: strcat (buf, "SECOND"); break;
00047 case DB_FRACTION: strcat (buf, "FRACTION"); break;
00048 }
00049
00050 if (from)
00051 strcat (buf, " to");
00052 if (to)
00053 strcat (buf, " ");
00054
00055 switch (to)
00056 {
00057 case DB_YEAR: strcat (buf, "YEAR"); break;
00058 case DB_MONTH: strcat (buf, "MONTH"); break;
00059 case DB_DAY: strcat (buf, "DAY"); break;
00060 case DB_HOUR: strcat (buf, "HOUR"); break;
00061 case DB_MINUTE: strcat (buf, "MINUTE"); break;
00062 case DB_SECOND: strcat (buf, "SECOND"); break;
00063 case DB_FRACTION: strcat (buf, "FRACTION"); break;
00064 }
00065
00066 return buf;
00067 }