PL/pgSQL
About
Creating
CREATE FUNCTION function_name(p1 type, p2 type, ...) RETURNS return_type AS
$$
BEGIN
-- statements
END;
$$ LANGUAGE plpgsqlExample
Calling
Running without Creating
Usage
Declaring variables
Overwrite variables names
Copying data types from table columns
Print variable values inside block
Using IN/OUT without RETURNS
Returning multiple values
Subblocks
Access outer blocks variables
Retuning query results
Control structure
if else
case
loop
for loops
foreach
while
continue
Executing other sql commands inside
Last updated