Next: , Previous: , Up: The (database postgres*) Modules   [Contents][Index]


10 Octet Molding/Mashing

Normally, the result of a pg-exec query is an object from which Scheme strings can be extracted to represent the datum from a particular tuple/field coordinate, using pg-getvalue (see Procedures for Retrieving Data). If this string is sufficient for your needs, you can skip this chapter, which describes Guile-PG facilities for transforming those strings to Scheme objects (i.e., molding) and back (i.e., mashing).

Which transform (or conversion, used equivalently in this manual) to use depends on the “SQL type” of a particular datum. Guile-PG distinguishes between the type name, a Scheme symbol used in Scheme programs, and the type SQL name, a Scheme string intended for eventual inclusion in a string to be passed to pg-exec (see Query Construction). For non-array types, these have the “same spelling”; for array types, they are different. Some examples:

SQL type
(concept)
type name
(symbol)
type SQL name
(string)
int4int4"int4"
DOUBLE PRECISIONfloat8"float8"
text “matrix”**text"text[][]"

Note how ‘DOUBLE PRECISION’ has a seemingly unrelated spelling for concept and type name. Also, the type name and the type SQL name differ for the text (two-dimensional) array type. Guile-PG procedures generally take the type name (symbol), so for brevity some of the parameter names in this chapter are called type instead of type-name.

To get started, load the postgres-types module:

(use-modules (database postgres-types))

Next: Column Definitions, Previous: Query Construction, Up: The (database postgres*) Modules   [Contents][Index]