In PostgreSQL, stored procedures can be used for pretty much everything. In this chapter, you have already learned about 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 CREATE CAST clause:
test=# h CREATE CAST
Command: CREATE CAST
Description: define a new cast
Syntax:
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 CAST (source_type AS target_type)
WITH INOUT
[ AS ASSIGNMENT | AS IMPLICIT ]
Using this stuff is very simple. You simply tell PostgreSQL which procedure...