postgresql_16:5.3.6 pgtypes Library
PostgreSQL 16 > Client Interfaces > ECPG — Embedded SQL in C > pgtypes Library
The pgtypes library maps PostgreSQL database types to C equivalents that can be used in C programs. It also offers functions to do basic calculations with those types within C, i.e., without the help of the PostgreSQL server. See the following example: EXEC SQL BEGIN DECLARE SECTION; date date1; timestamp ts1, tsout; interval iv1; char *out; EXEC SQL END DECLARE SECTION; PGTYPESdate_today(&date1); EXEC SQL SELECT started, duration INTO :ts1, :iv1 FROM datetbl WHERE d=:date1; PGTYPEStimestamp_add_interval(&ts1, &iv1, &tsout); out = PGTYPEStimestamp_to_asc(&tsout); printf("Started + duration: %s\n", out); PGTYPESchar_free(out);
Subsections
- postgresql_16:5.3.6.1 Character Strings
- postgresql_16:5.3.6.2 The numeric Type
- postgresql_16:5.3.6.3 The date Type
- postgresql_16:5.3.6.4 The timestamp Type
- postgresql_16:5.3.6.5 The interval Type
- postgresql_16:5.3.6.6 The decimal Type
- postgresql_16:5.3.6.7 errno Values of pgtypeslib
- postgresql_16:5.3.6.8 Special Constants of pgtypeslib