GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
sqlCtype.c
Go to the documentation of this file.
1 /*!
2  \file lib/db/dbmi_base/sqlCtype.c
3 
4  \brief DBMI Library (base) - SQL data type to C data type
5 
6  (C) 1999-2009, 2011 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Joel Jones (CERL/UIUC), Radim Blazek
12  \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
13 */
14 
15 #include <grass/dbmi.h>
16 
17 /*!
18  \brief Get C data type based on given SQL data type
19 
20  \param sqltype SQL data type
21 
22  \return related C data type
23 */
24 int db_sqltype_to_Ctype(int sqltype)
25 {
26  switch (sqltype) {
28  return DB_C_TYPE_INT;
30  return DB_C_TYPE_INT;
31  case DB_SQL_TYPE_REAL:
32  return DB_C_TYPE_DOUBLE;
34  return DB_C_TYPE_DOUBLE;
35  case DB_SQL_TYPE_SERIAL:
36  return DB_C_TYPE_INT;
37  }
38 
39  switch (sqltype & ~DB_DATETIME_MASK) {
40  case DB_SQL_TYPE_DATE:
41  case DB_SQL_TYPE_TIME:
44  return DB_C_TYPE_DATETIME;
45  }
46 
47  return DB_C_TYPE_STRING;
48 }
#define DB_SQL_TYPE_INTEGER
Definition: dbmi.h:83
#define DB_SQL_TYPE_INTERVAL
Definition: dbmi.h:91
#define DB_SQL_TYPE_TIMESTAMP
Definition: dbmi.h:90
#define DB_C_TYPE_DATETIME
Definition: dbmi.h:110
#define DB_SQL_TYPE_REAL
Definition: dbmi.h:84
#define DB_SQL_TYPE_SERIAL
Definition: dbmi.h:94
#define DB_SQL_TYPE_DATE
Definition: dbmi.h:88
int db_sqltype_to_Ctype(int sqltype)
Get C data type based on given SQL data type.
Definition: sqlCtype.c:24
#define DB_C_TYPE_STRING
Definition: dbmi.h:107
#define DB_C_TYPE_INT
Definition: dbmi.h:108
#define DB_SQL_TYPE_DOUBLE_PRECISION
Definition: dbmi.h:85
#define DB_C_TYPE_DOUBLE
Definition: dbmi.h:109
#define DB_SQL_TYPE_TIME
Definition: dbmi.h:89
#define DB_SQL_TYPE_SMALLINT
Definition: dbmi.h:82
#define DB_DATETIME_MASK
Definition: dbmi.h:104