/* Map Informix INTERVAL types to equivalent ODBC types */ static int ivmap(int collen) { int tu_s = TU_START(collen); int tu_e = TU_END(collen); int odbctype; if (tu_s == TU_YEAR && tu_e == TU_YEAR) odbctype = SQL_INTERVAL_YEAR; else if (tu_s == TU_YEAR && tu_e == TU_MONTH) odbctype = SQL_INTERVAL_YEAR_TO_MONTH; else if (tu_s == TU_MONTH && tu_e == TU_MONTH) odbctype = SQL_INTERVAL_MONTH; else if (tu_s == TU_DAY && tu_e == TU_DAY) odbctype = SQL_INTERVAL_DAY; else if (tu_s == TU_DAY && tu_e == TU_HOUR) odbctype = SQL_INTERVAL_DAY_TO_HOUR; else if (tu_s == TU_DAY && tu_e == TU_MINUTE) odbctype = SQL_INTERVAL_DAY_TO_MINUTE; else if (tu_s == TU_DAY && tu_e >= TU_SECOND) odbctype = SQL_INTERVAL_DAY_TO_SECOND; else if (tu_s == TU_HOUR && tu_e == TU_HOUR) odbctype = SQL_INTERVAL_HOUR; else if (tu_s == TU_HOUR && tu_e == TU_MINUTE) odbctype = SQL_INTERVAL_HOUR_TO_MINUTE; else if (tu_s == TU_HOUR && tu_e >= TU_SECOND) odbctype = SQL_INTERVAL_HOUR_TO_SECOND; else if (tu_s == TU_MINUTE && tu_e == TU_MINUTE) odbctype = SQL_INTERVAL_MINUTE; else if (tu_s == TU_MINUTE && tu_e >= TU_SECOND) odbctype = SQL_INTERVAL_MINUTE_TO_SECOND; else if (tu_s >= TU_SECOND && tu_e >= TU_SECOND) odbctype = SQL_INTERVAL_SECOND; else { /** ** Should never happen. ** ODBC supports all interval types Informix does */ odbctype = SQL_CHAR; } return(odbctype); }
/* Map Sqlflex DATETIME types to equivalent ODBC types */ static int dtmap(int collen) { int tu_s = TU_START(collen); int tu_e = TU_END(collen); int odbctype; /** ** Most of Sqlflex's DATETIME types do not have corresponding ODBC types. ** Regard them as undefined types (SQL_TYPE_NULL). */ if (tu_s == TU_YEAR && tu_e == TU_DAY) odbctype = SQL_DATE; else if (tu_s == TU_YEAR && tu_e >= TU_SECOND) odbctype = SQL_TIMESTAMP; else if (tu_s == TU_HOUR && tu_e >= TU_SECOND) odbctype = SQL_TIME; else odbctype = SQL_CHAR; return(odbctype); }