In PostgreSQL, stored procedures can be used for pretty much everything. In this chapter, you have already learned about the CREATE DOMAIN clause and so on, but it is also possible to create your own operators, type casts, and even collations.
In this section, you will see how a simple type cast can be created and how it can be used to your advantage. To define the type cast, consider taking a look at the CREATE CAST clause:
test=# \h CREATE CAST Command: CREATE CASTDescription: Define a new castSyntax:CREATE CAST (source_type AS target_type) WITH FUNCTION function_name (argument_type [, ...]) [ AS ASSIGNMENT | AS IMPLICIT ] CREATE CAST (source_type AS target_type) WITHOUT FUNCTION [ AS ASSIGNMENT | AS IMPLICIT ] CREATE ...