Exploring functions and languages
PostgreSQL is capable of executing server-side code. There are many ways to provide PostgreSQL with the code to be executed. For example, the user can create functions in different programming languages. The main languages supported by PostgreSQL are as follows:
- SQL
- PL/pgSQL
- C
These listed languages are the built-in languages; there are also other languages that PostgreSQL can manage, but before using them, we need to install them on our system. Some of these other supported languages are as follows:
- PL/Python
- PL/Perl
- PL/tcl
- PL/Java
In this section, we’ll talk about SQL and PL/pgSQL functions.
Functions
The command structure with which a function is defined is as follows:
CREATE FUNCTION function_name(p1 type, p2 type,p3 type, ....., pn type)
RETURNS type AS
BEGIN
-- function logic
END;
LANGUAGE language_name
The following steps always apply to any type...