Updated on 2024-05-07 GMT+08:00

Type Mapping

When ecpg applications exchange values between the GaussDB Kernel server and the C program, such as when retrieving query results from the server or executing SQL statements with input parameters, the values need to be converted between GaussDB Kernel data types and host language variable types (C language data types, concretely). There are two data types available: Simple GaussDB Kernel data types, such as integer and text, can be directly read and written by applications. Other GaussDB Kernel data types, such as timestamp and numeric, can be accessed only by using special library functions. For details, see ECPG API Reference.

Table 1 Mapping between GaussDB Kernel data types and C variable types

GaussDB Kernel Data Type

Host Variable Type

smallint

short

integer

int

bigint

long long int

boolean

boolean

character(n), varchar(n), text

char[n+1], VARCHAR[n+1]

double precision

double

real

float

smallserial

short

serial

int

bigserial

long long int

oid

unsigned int

name

char[NAMEDATALEN]

date

date [a]

timestamp

timestamp [a]

interval

interval [a]

decimal

decimal [a]

numeric

numeric [a]

[a] This type can be accessed through Accessing Special Data Types.

  • Currently, only basic data types of the C language can be used or combined. The string data type in the C++ language cannot be used as the host variable type.
  • Currently, ecpg maps only common data types of GaussDB Kernel SQL. For details about the supported data types, see Table 1.