3.12. Casts
Casts are objects used to convert values between two different data types. PostgreSQL implements several type casts, but the user has the freedom to create custom casts to provide, for instance, the conversion between user-defined types and built-in data types and vice versa. Casts are simple objects in their configuration since the hard work is done by the cast function itself. The editing dialog of this kind of object is detailed as follows:
123456789
| General | |||
|---|---|---|---|
| # | Field | Group box | Description |
| 1 | Cast type | Defines the cast mode.
| |
| 2 | Input / Output | Cast type | Converts the value using the output function of the source data type and passes the resulting string to the input function of the target type, instead of using a cast function ( |
| 3 | Cast function | The function that performs the value conversion. It must have the signature | |
| 4 | Type | Source data type | The data type. Besides the built-in types, the list also holds the user-defined types, domains and other types of the model. |
| 5 | Dimension | Source data type | Number of dimensions when the type is an array ( |
| 6 | Type | Target data type | The data type. Besides the built-in types, the list also holds the user-defined types, domains and other types of the model. |
| 7 | Dimension | Target data type | Number of dimensions when the type is an array ( |
| 8 | Format | Source data type | Read-only preview of the data type as it is written in the SQL code, with length, precision, dimension and other modifiers applied. |
| 9 | Format | Target data type | Read-only preview of the data type as it is written in the SQL code, with length, precision, dimension and other modifiers applied. |
References
Cast DDL
https://www.postgresql.org/docs/current/static/sql-createcast.html